home
training courses
why choose us?
solutions
support
company
LearnItFirst User Forum
Welcome Guest
Search
|
New Posts
|
Members
|
Log In
|
Register
SQL Server Forum - LearnItFirst.com
»
Transact-SQL Programming
»
DML (SELECT, INSERT, UPDATE, DELETE) Questions
»
Problem COMMIT with MARS connections enable (ODBC)
Problem COMMIT with MARS connections enable (ODBC)
Options
Previous Topic
·
Next Topic
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 :
1°
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)
2°
set implicit_transaction to ON :
SQLExecDirect(stmt, "SET IMPLICIT_TRANSACTIONS ON", strlen("SET IMPLICIT_TRANSACTIONS ON"
)
3°
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]
4°
Then execute :
SQLExecute(curs->stmt)
No problem/error until that point.
5°
Want to commit :
SQLExecDirect(stmt, "COMMIT", strlen("COMMIT"
)
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
Back to top
Scott Whigham
Posted:
Monday, March 30, 2009 10:59:37 AM
Rank: Super Mod
Joined: 3/20/2006
Posts: 476
Points: 1,053
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?
Back to top
Users browsing this topic
Guest
Forum Jump
SQL Server Database Administration
- General SQL Database Question & Answer
- Backup, Recovery and Disaster Recovery
- SQL Server Security
- Integration Services (SSIS) and DTS
Transact-SQL Programming
- DML (SELECT, INSERT, UPDATE, DELETE) Questions
- Stored Procedures, Triggers, & Functions
SQL Server Scripts, Code Samples and SSMS Custom Reports
- All SQL Server Versions
- SQL Server 2005/2008
- SQL Server Management Studio Custom Reports
Customer Service
- Video Requests
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.
SQL Server 2005 DBA Training Videos
SQL Server 2008 DBA Training Videos
Email this topic
RSS Feed
Watch this topic
Print this topic
Normal
Threaded