How an Application Program Initiates a Transaction

An application program initiates a transaction by:

  1. Connecting to MS DTC and obtaining a transaction dispenser interface that it uses to initiate transactions.
  2. Opening the appropriate resource managers, for example, by connecting to a relational database using ODBC.
  3. Initiating the MS DTC transaction by calling BeginTransaction and obtaining a transaction object that represents the transaction.
  4. Propagating the transaction to each resource manager by invoking the resource manager’s transaction enlistment interface.

For example, the application program uses the ODBC SQLSetConnectOption to propagate the MS DTC transaction object to resource managers that support ODBC. All subsequent work done on the ODBC connection is performed as part of the transaction. When the resource manager becomes aware of the MS DTC transaction, it enlists in the transaction with its local MS DTC transaction manager. This permits the resource manager to participate in the two-phase commit protocol and to receive transaction commit or abort notifications from MS DTC.

  1. Invoking the normal resource manager functions that update transaction-protected resource manager data.

For example, the application might insert, delete, or update records in a relational database, or it might invoke a database stored procedure that modifies the relational database.

  1. Calling Commit when the work of the transaction is complete. In response to the Commit call, MS DTC uses the two-phase commit protocol to coordinate commitment of the transaction with all of the resource managers enlisted in the transaction. Alternatively, the application program could call Abort to undo the effects of the transaction. The application may then go on to perform more MS DTC transactions.
  2. Releasing the transaction dispenser object and closing the ODBC connections when the application program completes.

Application programs that initiate MS DTC transactions must reside on a system on which either the Complete MS DTC Service or the MS DTC Client Utilities has been installed. The resource manager must reside on a system on which the Complete MS DTC Service has been installed. For information on installation and configuration of MS DTC, refer to "Setting Up an MS DTC System" in the MS DTC Administrator's Guide and Programmer’s Reference.