Forum Moderators: open

Message Too Old, No Replies

Transaction Problem

         

charonlee

7:39 am on May 20, 2003 (gmt 0)

10+ Year Member



I really wonder about the Con.Errors.Count, please look at these two condition.
Condition A
Con.BeginTrans
con.Execute(Update SQL) //first Update SQL Statemenr
strSQL = "Select * From Invalid Table Where Cat = C"
Set Rs = Con.Execute(strSQL)
If Con.Errors.Count > 0 Then
Con.RollbackTrans
Error msg
Else

If Not Rs.EOF Then
Con.Execute "Update SQL2"
Con.CommitTrans
Else
Con.Execute "Update SQL3"
Con.CommitTrans
End If
End If

Condition B
Con.BeginTrans
con.Execute(Update SQL)
strSQL = "Select * From InvalidTable Where Cat = C"
Set Rs = Con.Execute(strSQL)
If Not Rs.EOF Then
Con.Execute "Update SQL2"
Else
Con.Execute "Update SQL3"

End If

If Con.Errors.Count > 0 Then
Con.RollbackTrans
Else
Con.CommitTrans
End If

Term and Condition:
a.)The first Update Statement must be executed before the SELECT statement
b.)The second / third Update must be executed if the first Update statement is executed successfully, else Rollback. none of them is executed

1.) The Condition A manage to catch the error which occur at SELECT statement (invalid table) and Rollback the first Update SQL statement
2.) In the Condition A, Second/third Update statement not executed
3.) But this is not a proper way as it can't detect if the Second/third Update statement is executed correctly


1.) The condition B not manage to detect the error at If Con.Errors.Count > 0 Then, so it Commits the transaction instead of Rollback, result in unproper data is updated. WHY, does it should works as in Condition A.
2.) In condition B, the second third Update statement (SQL3) is executed. But it is not corrected as the Value which going to updated must depend on the SELECT statement.


Please help..please....I'm lost

jeremy goodrich

7:07 pm on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any ASP experts in the crowd wanna take a stab at this one? I'm a Perl / linux type of guy, so this transaction / microsoft stuff is a bit like greek for me.