Tuesday, March 20, 2012

A transaction that was started in a MARS batch is still active at the end of the batch. The tran

I'm using SQL Server 2005 via ODBC, MARS enabled. I get an error when i try to start explicit transaction// Enable MARSSQLSetConnectAttr(cDbc, SQL_COPT_SS_MARS_ENABLED, (PTR)SQL_MARS_ENABLED_YES, SQL_IS_UINTEGER)..// Connect to Datasource.SQL DriverConnect(.......// Executing begin transactionSQLExecDirect(cStmt, "BEGIN TRANSACTION",lstrlen("BEGIN TRANSACTION") );SQLState 37000

[Microsoft][SQL Native Client][SQL Server]A transaction that was

started in a MARS batch is still active at the end of the batch. The

transaction is rolled back.

Native Error 3997So what is wrong with my codethanks in advance grs

With MARS enabled, transaction that span a single request need to started using API call -- this is required in order to synchronize the "explicit transaction" state change at the connection level with request activity in the connection. See the following blog entry from Chihan for more details.

http://blogs.msdn.com/cbiyikoglu/archive/2006/11/21/mars-transactions-and-sql-error-3997-3988-or-3983.aspx

Regards

G2

No comments:

Post a Comment