Programming for MS DTC

StepsTo program using Microsoft Distributed Transaction Coordinator (MS DTC)

  1. Connect to MS DTC by using the DtcGetTransactionManager function. For information about MS DTC, see Microsoft Distributed Transaction Coordinator documentation.

  2. Call SQLDriverConnect or SQLConnect once for each Sybase ASE connection you want to establish.

  3. Call the ITransactionDispenser::BeginTransaction function to begin an MS DTC transaction and to obtain an OLE Transaction object that represents the transaction.

  4. Call SQLSetConnectAttr one or more times for each ODBC connection you want to enlist in the MS DTC transaction. SQLSetConnectAttr must be called with an attribute of SQL_ATTR_ENLIST_IN_DTC and a ValuePtr of the Transaction object (obtained in step 3).

  5. Call SQLExecDirect one or more times for each insert or update SQL statement.

  6. Call the ITransaction::Commit function to commit the MS DTC transaction. The Transaction object is no longer valid.

To perform a series of MS DTC transactions, repeat steps 3 through 6.To release the reference to the Transaction object, call the ITransaction::Release function.To use an ODBC connection with an MS DTC transaction and then use the same connection with a local ASE Server transaction, call SQLSetConnectAttr with a ValuePtr of SQL_DTC_DONE to unenlist the connection from the transaction.

NoteAlso, you can call SQLSetConnectAttr and SQLExecDirect separately for each ASE Server, instead of calling them as suggested in steps 4 and 5.