Database.CommitTransaction

From Xojo Documentation

Method

Database.CommitTransaction()

New in 2019r2

Supported for all project types and targets.

Commits an open transaction. This permanently saves changes to the database.

Exceptions

Exception Reason
DatabaseException Raised if the transaction could not be committed.

Notes

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

BEGIN TRANSACTION

It can be sent using ExecuteSQL:

DB.ExecuteSQL("BEGIN TRANSACTION")

Sample Code

You typically want to Commit changes after ensuring there were no database errors:

// Prior DB code has run

Try
DB.CommitTransaction
Catch error As DatabaseException
MsgBox("Error: " + error.Message)
DB.RollbackTransaction
End Try

See Also

Database.Close, Database.RollbackTransaction