Database.Rollback

From Xojo Documentation
Jump to: navigation, search
Method

Database.Rollback()

Cancels an open transaction restoring the database to the state it was in before the transaction began.

Notes

You will generally want to rollback database changes if a database error occurs within the transaction.

You have to have an open transaction to be able to use Rollback. On SQLite (and other databases), you can start a transaction with this command:

 BEGIN TRANSACTION

It can be sent using SQLExecute:

DB.SQLExecute("BEGIN TRANSACTION")

Example

This example uses rollback to revert database changes in a transaction when an error occurs:

// Prior DB code has run

If Not DB.Error Then
DB.Commit
Else
MsgBox("Error: " + DB.ErrorMessage)
DB.Rollback
End If

See Also

Database.Close, Database.Commit

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About