Click to open or copy the files for the ODBC sample.
This is a sample C++ program using 32-bit Visual C++ and the ODBC interface to communicate with both MS DTC and SQL Server.
This example uses MS DTC (distributed transaction coordinator) to perform simultaneous updates on two SQL Servers. The transaction in this example is client-initiated. The client also initiates the commit operation.
This sample uses the ODBC interface, so you need to configure ODBC data source names for two SQL servers that you can use to run this sample. Each DSN (data source name) must point to the pubs database in a separate SQL Server. The authors table in the pubs database is used in this sample.
This sample uses the following keywords:
begintransaction; commit; dosqlerror; dtcgettransactionmanager; enlist; executestatement; exit; failed; freeodbchandles; initglobals; logontodb; lstrcpy; printf; processrc; ptransaction-release; release; sprintf; sqlallocconnect; sqlallocenv; sqlallocstmt; sqlconnect; sqldisconnect; sqlerror; sqlexecdirect; sqlfreeconnect; sqlfreeenv; sqlfreestmt