Method

Database_Class.Rollback


Warning

This item was deprecated in version 2019r2. Please use Database.RollbackTransaction as a replacement.

Description

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: <pre class="code">BEGIN TRANSACTION</pre>

It can be sent using SQLExecute:

DB.SQLExecute("BEGIN TRANSACTION")

Sample code

This code 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

Compatibility

All project types on all supported operating systems.