Transaction Control to access database via OLEDB

forum.connectivity (2000-2005) & forum.td.connectivity (2005-2010)
NewsgroupServer
Robot
Robot
Posts: 115421
Joined: 24 Feb 2017, 12:00
Location: World wide

Transaction Control to access database via OLEDB

Post by NewsgroupServer » 18 Feb 2009, 10:01

 Posted by:  Thiel Kohpeiß 

Hi All,

further I used ODBC to connect to a acess database and got transaction
control working through several odbc params set in the odbc definition.

Now I try to make a OLEDB connection to a access database and didn't
find a way to initialize a transaction.

If I try to send a commit I got the message:
"Err No: -69010462 :Sie haben versucht, eine Transaktion zu Ende zu
führen (Commit) oder zurückzusetzen (Rollback), ohne zuvor die
BeginTrans-Methode zu verwenden.; "
Tranlated:
"... you tried to end a transaction (commit) or abort a transaction
(rollback) without using BeginTrans Method before..."

How can I turn of the autocommit mode?
How can I init an transaction so have possibility of commit and rollback?

I'm using connect string as follows:
Set l_strSession = 'Jet OLEDB:Transaction Commit
Mode=0;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' || p_strDBFile ||
';Mode=Share Deny Read|Share Deny Write;Persist Security Info=False'

I tried also:
Call SqlSetSessionParameter( w_hSession, DBP_AUTOCOMMIT, FALSE,
STRING_Null )

without success.

Can someone give me a hint?

best regards
Thiel
(Germany)

NewsgroupServer
Robot
Robot
Posts: 115421
Joined: 24 Feb 2017, 12:00
Location: World wide

Transaction Control to access database via OLEDB

Post by NewsgroupServer » 18 Feb 2009, 12:16

 Posted by:  Rainer Ebert 

In some tests I did it with SqlSetParameter(hSql, DBP_AUTOCOMMIT, FALSE, '')
on the cursor, not on the session handle.
Rainer

NewsgroupServer
Robot
Robot
Posts: 115421
Joined: 24 Feb 2017, 12:00
Location: World wide

Transaction Control to access database via OLEDB

Post by NewsgroupServer » 18 Feb 2009, 15:18

 Posted by:  Thiel Kohpeiß 

Both will bring no changes in my testcase (SqlSetSessionParameter,
SqlSetParameter).

But I found the sql word to start a transaction, which is accepted by
the jet engine:

begin transaction
...
commit

Will be accepted and seems to work. It is also possible to nest
transactions like this:

begin transaction
...
begin transaction
...
commit
...
rollback

but with incorrect usage of these blocks, I loose connection to the
database. But this could be avoided (at least with reconnect on this
special error).

So it seems to work.

Thanks for your hint

Thiel

(Tested with 5.1, jet4.0)

Return to “td.connectivity”

Who is online

Users browsing this forum: [Ccbot] and 0 guests