LearnItFirst User Forum

New SQL Server 2008 DBA Course
Welcome Guest Search | New Posts | Members | Log In | Register

Problem COMMIT with MARS connections enable (ODBC) Options
Yan302
Posted: Friday, March 27, 2009 5:08:08 AM
Rank: Newbie

Joined: 3/27/2009
Posts: 1
Points: 3
Hi all,

I've got trouble using commit with MARS connection enable.
Here is my steps :

Wink Connection :
connectString = Driver={SQL Native Client};Server=BROL\SQLEXPRESS; Database=test;Trusted_Connection=Yes;MARS_Connection=Yes;"

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &ODBCenv)
SQLSetEnvAttr(ODBCenv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER *)SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, ODBCenv, &ODBCcon)
SQLDriverConnect(ODBCcon, NULL, connectString, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT)

Wink set implicit_transaction to ON :
SQLExecDirect(stmt, "SET IMPLICIT_TRANSACTIONS ON", strlen("SET IMPLICIT_TRANSACTIONS ON"Wink)

Wink Alloc, prepare and bind for an insert statement :
SQLAllocHandle(SQL_HANDLE_STMT, ODBCcon,&(curs->stmt)
SQLPrepare(curs->stmt, curs->str, strlen(curs->str)
[some bind]

Wink Then execute :
SQLExecute(curs->stmt)

No problem/error until that point.

Wink Want to commit :
SQLExecDirect(stmt, "COMMIT", strlen("COMMIT"Wink)

And there I got the error :
"The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION."

But in fact, a begin transaction should not be present while IMPLICIT_TRANSACTION is set to ON. If I remove the option "Mars Connection" from the connection string ; I don't have the problem anymore but I need this option.

Someone got any idea ?

Thanks,

Yan302
Scott Whigham
Posted: Monday, March 30, 2009 10:59:37 AM


Rank: Super Mod

Joined: 3/20/2006
Posts: 460
Points: 1,002
Where do you live?: Dallas, TX
Have you used Profiler to verify that your code is getting executed in the order you think it is?
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.