Roll back transaction Error handling 
Author Message
 Roll back transaction Error handling

How do I prevent this scenario?
I have a routine that such as the following.

on error goto errHandler

validation code etc.

.BeginTrans
rst edits etc.
.committrans
exit sub
errHandler:
rollback

Everything is fine unless an error occurs before the begintrans line then my
error handler returns an error because I try to rollback a trans without
begintrans.
How do I handle this?



Wed, 31 Oct 2001 03:00:00 GMT  
 Roll back transaction Error handling
Dim a boolean value i.e. Dim fTranInEffect as boolean.
Set that value to True immediately after invoking BeginTrans.
Set that value to False immediately after invoking CommitTrans.
In your error hanlder
    If fTranInEffect = true then
        we.rollback
    End if

Good luck,
Doug



Wed, 31 Oct 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RDO Problem when rolling back transaction - Function sequence error

2. Rolling back transactions

3. COM+ question: SetAbort not rolling back transaction?

4. MTS, VB and rolling back transactions

5. SetAbort does not roll back transaction

6. Error handling and Database Transactions

7. Error Handling: SQL Server Transaction Locks

8. Error handling and Database Transactions

9. Error handling and Database Transactions

10. Error handling and Database Transactions

11. Rolling Averages - back to the drawing board

12. committing/rolling back all changes on form

 

 
Powered by phpBB® Forum Software