API Implicit Transactions
The API mechanisms used to set implicit transactions are ODBC and OLE DB.
- Call the SQLSetConnectAttr function with Attribute set to SQL_ATTR_AUTOCOMMIT and ValuePtr set to SQL_AUTOCOMMIT_OFF to start implicit transaction mode.
- The connection remains in implicit transaction mode until you call SQLSetConnectAttr with Attribute set to SQL_ATTR_AUTOCOMMIT and ValuePtr set to SQL_AUTOCOMMIT_ON.
- Call the SQLEndTran function with CompletionType set to either SQL_COMMIT or SQL_ROLLBACK to commit or roll back each transaction.
- When SQL_AUTOCOMMIT_OFF is set by an ODBC application, the Microsoft® SQL Server™ ODBC driver issues a SET IMPLICIT_TRANSACTION ON statement.
OLE DB does not have a method to set implicit transaction mode specifically.
- Call the ITransactionLocal::StartTransaction method to start an explicit transaction.
- When you then call either the ITransaction::Commit or ITransaction::Abort method with fRetaining set to TRUE, OLE DB completes the current transaction and goes into implicit transaction mode. The connection remains in implicit transaction mode as long as you set fRetaining on ITransaction::Commit or ITransaction::Abort to TRUE.
- Call ITransaction::Commit or ITransaction::Abort with fRetaining set to FALSE to stop implicit transaction mode.
ADO does not support implicit transactions. ADO applications use either autocommit mode or explicit transactions.