Database.BeginTransaction
From Xojo Documentation
Method
Creates a new transaction. Changes to the database made after this call can be saved with CommitTransaction or undone with RollbackTransaction.
Exceptions
Exception | Reason |
---|---|
DatabaseException | Raised if the transaction could not begin or another transaction is already in progress. |
Sample Code
You typically want to Commit changes after ensuring there were no database errors:
// Prior DB code has run
Try
DB.BeginTransaction
DB.ExecuteSQL("CREATE TABLE 'AddressBook' name varchar, email varchar")
DB.CommitTransaction
Catch error As DatabaseException
MsgBox("Error: " + error.Message)
DB.RollbackTransaction
End Try
Try
DB.BeginTransaction
DB.ExecuteSQL("CREATE TABLE 'AddressBook' name varchar, email varchar")
DB.CommitTransaction
Catch error As DatabaseException
MsgBox("Error: " + error.Message)
DB.RollbackTransaction
End Try
See Also
Database.Close, Database.CommitTransaction, Database.RollbackTransaction