PDA

Click to See Complete Forum and Search --> : BeginTrans/RollBack/CommitTrans


jaroh
Jul 27th, 2000, 04:31 AM
Whats the best way to implement a (ADO) Rollback
in case there was an unexpected error during processing.

I was trying to put the code in the "ON ERROR GOTO" routine but it says that there was no active transaction....Pls. I need your help.

Tnx in advance.

CGTS
Jul 27th, 2000, 05:09 AM
Did you set the transaction in progress earlier in your code.... i.e.

assuming your connection variable is called cn and recordset is rs.

------------------------------------------------------------
On Error Goto ErrorTrap

sub DoSomething()

cn.begintrans

with rs
.addnew
.fields("txtData") = "test"
'Assume this next field should be an integer it will cause an error
.fields("intData") = "someText"
.update
end with
cn.CommitTrans

Out:
Exit Sub
ErrorTrap:
cn.rollbackTrans
resume Out:
End sub