Database.RollbackTransaction
From Xojo Documentation
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site! |
Method
Cancels an open transaction restoring the database to the state it was in before the transaction began.
Notes
A DatabaseException will be raised if the rollback could not be completed.
You will generally want to rollback database changes if a DatabaseException occurs within the transaction.
You have to have an open transaction to be able to use Rollback. Call BeginTransaction to begin a transaction:
DB.BeginTransaction
Sample Code
This code uses rollback to revert database changes in a transaction when an error occurs:
// Prior DB code has run
Try
db.CommitTransaction
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
db.RollbackTransaction
End If
Try
db.CommitTransaction
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
db.RollbackTransaction
End If