Solved

How can I change IMPLICIT TRANSACTIONS ON

Posted on 1998-06-25
7
979 Views
Last Modified: 2008-02-01
The new question is: Can I get from my Visual C++ code the same behaviour than turning off the
"Generate Stored Procedure for Prepared Statement" in the Control Panel's ODBC
configuration?

I'd also like to know what exactly IMPLICIT TRANSACTIONS OFF means (I think that it was
IMPLICIT TRANSACTIONS ON before the ODBC driver that comes with SQL Server 6.5). How
can I change IMPLICIT TRANSACTIONS to ON from my C++ code? Will that mean that SQL
Server will release that temporary stored procedures from tempdb after every insert/update
(supposing I turn on the "Generate Stored Procedure for Prepared Statement" in the ODBC
configuration)?
0
Comment
Question by:davidjava
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:connex
ID: 1091619
a)
  Just change the Registry Key:
    HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\<DSN-Name>\UseProcForPrepare to "No"

b)
  Issue the SQL-Command
   "SET IMPLICIT_TRANSACTIONS ON" via SQLExecDirect Call.
 
  This means that the SQL-Server will automatically use transactions for the Commands
    fetch,delete,insert,create,alter table,open,grant,revoke
    drop,truncate table,select,update
  (see Transact SQL-Help about the SET-Statement)

0
 

Author Comment

by:davidjava
ID: 1091620
Thank you again CONNEX. Your answer is quite good but I still do not know which is the relation between the IMPLICIT TRANSACTIONS ON or OFF and the "Generate Stored Procedure for Prepared Statement".

I tried to run the program with the "Generate Stored Procedure" checkbox enabled in the Control Panel and the IMPLICIT TRANSACTIONS ON (activated using CDatabase::ExecuteSQL("SET IMPLICIT_TRANSACTIONS ON") after the CDatabase::Open() call), and the program hung in the next CRecordset::Open() call. I do not know why... On the other hand, it runs ok when I disable the checkbox in the Control Panel.

0
 
LVL 2

Expert Comment

by:connex
ID: 1091621
Hmm works fine with ,my application ...
What exactly are you doing inbetween the calls?
Do you commit your transactions? or are you using autocommit?

0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 2

Expert Comment

by:connex
ID: 1091622
Oops forgot that part .)
There is quite a large article about that in the Technical articles about ODBC. Maybe you have a look at the MS Support pages just search for "implicit and transaction and odbc and stored and procedure"
It's too huge to post it here


0
 
LVL 7

Expert Comment

by:spiridonov
ID: 1091623
Generate stored procedures for prepared statement has nothing to do with implicit transactions setting.
Generate... option is used by JET to optimize repeated parameter queries. It is quicker to call prepared stored procedure with a parameter, then do "Select .. where parameter_criteria"

Implicit transactions on means, that each statement issued agains  t SQL server database is automatically commited.
Implicit transaction off means, that you have to begin and commit transaction explicitly.


0
 

Author Comment

by:davidjava
ID: 1091624
Thank you CONNEX. The article you suggested was all what I needed. In fact, the two articles,
http://support.microsoft.com/support/kb/articles/Q135/5/32.asp and
http://support.microsoft.com/support/kb/articles/q151/5/36.asp
were very interesting. They explain the new configuration options for SQL Server 6.5 which are not included in the SQL Server documentation nor in the Visual C++ 5.0 help.

The only you need is to copy the odbcss.h file from the SQL Server 6.5 Service Pack 3 and then you are able to use the following instructions,
SQLSetConnectOption(hdbc, SQL_USE_PROCEDURE_FOR_PREPARE,
SQL_UP_ON_DROP)
SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_ON)

It seems to work fine. The first instruction makes SQL Server to delete the temporary stored procedures it creates on each Prepare... wow! I am currently trying SQL_AUTOCOMMIT_OFF in order to compare the efficiency.

I also want to thank you SPIRIDONOV for your help, though I think that the points of this question must go to CONNEX as he gave me the clue. Hope you understand.

0
 
LVL 2

Accepted Solution

by:
connex earned 300 total points
ID: 1091625
Thanks .)
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Select2 jquery help 9 46
C# Application Local DB Connection String 23 61
while loop in html mail format 5 33
Test a query 23 18
In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now