dbenlisttrans
Enlists the current SQL Server connection in an existing MS DTC transaction.
Syntax
RETCODE dbenlisttrans (
PDBPROCESS dbproc,
LPVOID pTransaction );
where
-
dbproc
-
Is the DBPROCESS structure that is the handle for a particular workstation/SQL Server process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
-
pTransaction
-
Is the MS DTC transaction OLE object that specifies the transaction to export to SQL Server. The client calls the MS DTC OLE ITransactionDispenser::BeginTransaction method to create the MS DTC transaction object.
Returns
SUCCEED or FAIL.
Remarks
The client application must call dbenlisttrans before performing the first update on a SQL Server that is enlisted in an MS DTC transaction.
To update two or more (N) SQL Servers using MS DTC
-
Connect to the MS DTC by using the MS DTC OLE DtcSelectTransactionManager method to obtain a transaction manager object. For information about MS DTC, see the Guide to Microsoft Distributed Transaction Coordinator.
-
Call dbopen N times to connect to each SQL Server.
-
Call the MS DTC OLE ITransactionDispenser::BeginTransaction method to begin the MS DTC transaction and to obtain a transaction object.
-
Call dbenlisttrans N times to send the MS DTC transaction to each SQL Server.
-
Call dbsqlexec N times to perform one or more MS DTC transaction updates on each SQL Server.
-
Call the MS DTC OLE ITransaction::Commit method to commit the MS DTC transaction. The transaction object is no longer valid after the transaction commits.
-
Call the MS DTC OLE ITransaction::Return method to release the reference to the transaction object.
-
Either
-
Call dbenlisttrans N times to pass a NULL transaction pointer to each SQL Server, which will disconnect each SQL Server.
Or
-
To begin a new coordinated transaction, go to step 3.
Note You can also call dbenlisttrans and dbsqlexec in turn for each SQL Server instead of calling them as suggested in steps 4 and 5 above.
See Also
dbenlistxatrans