Database.CommitTransaction
From Xojo Documentation
Method
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
Try
DB.CommitTransaction
Catch error As DatabaseException
MsgBox("Error: " + error.Message)
DB.RollbackTransaction
End Try