ExecuteSync()
- Last UpdatedNov 25, 2015
- 1 minute read
Use the ExecuteSync() method to instruct the SQLData Script Library to run all commands that are queued as part of a transaction.
Syntax
Result ExecuteSync()
Remarks
Use the ExecutionState and LastExecutionError properties to check for status of this method.
If any one of the commands completes with an error, the SQLData Script Library issues a rollback action to guarantee that the data source does not see any of the changes.
When the transaction object runs, all aaDBCommand objects that are added to the aaDBTransaction are run in the order that they were added. The following outcomes can occur as the result of processing a transaction:
-
Success: All commands succeeded. Each command shows an ExecutionState of Completed. Any dataset for that command is associated with it.
-
Cancellation: Each command in the transaction shows an ExecutionState of Canceled. Any data associated with the command is removed.
-
Failure: When one command in a transaction fails, that command object has an ExecutionState of Failed. All command objects preceding it show an ExecutionState of Completed and retain any datasets that were part of their successful processing.
After ExecuteSync() is processed, you can still obtain a reference to the command objects that were added and analyze their ExecutionState and LastExecutionError properties.
Use the LastExecutionError property to check if the command failed or succeeded (success is indicated by a blank string), since ExecuteSync() may return 0 in the case of a failure instead of an error message.
To free all resources allocated for the aaDBTransaction object and the aaDBCommand objects you must call Dispose().