Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Transaction Problem

Author  Topic 

winz
Starting Member

5 Posts

Posted - 2003-05-20 : 06:32:11
I really wonder about the Transaction:

Condition A:

con.BeginTrans
con.Execute "Update [Names] Set Name = 'kong' Where ID = 20", RecordsEffected
con.Execute "Update [invalidTable] Set Name = 'wong' Where ID = 28", RecordsEffected


Condition B

con.BeginTrans
con.Execute "Update [invalidTable] Set Name = 'wong' Where ID = 28", RecordsEffected
con.Execute "Update [Names] Set Name = 'kong' Where ID = 20", RecordsEffected

If con.Errors.Count > 0 Then
con.RollbackTrans
Response.Write "Transaction Rollback" & err.Description

Else
con.CommitTrans
Response.Write "Transaction Commit & Record Effected is :" & RecordsEffected
End If


1.) If in condition A, the con.Errors.Count can't catch the Error, and commit the transaction, but In condition B it be able to catch the error and rollback the transaction

Pls help...WHY



robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-05-20 : 08:17:46
Don't do transactions in ADO. Rewrite this code as a stored procedure and use server-side transactions only.

Go to Top of Page
   

- Advertisement -