dbenlisttrans
Enlists the current Microsoft® SQL Server™ connection in an existing Microsoft Distributed Transaction Coordinator (MS DTC) transaction.
Syntax
RETCODE dbenlisttrans (
PDBPROCESS dbproc,
LPVOID pTransaction);
Arguments
- 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 object ITransactionDispenser::Begin Transaction 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 server running 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.
- 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 earlier.
See Also
(c) 1988-98 Microsoft Corporation. All Rights Reserved.