SQLConnection.StartTransaction does nothing

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Marcos

SQLConnection.StartTransaction does nothing

Post by Marcos » Wed 10 Nov 2004 19:34

Hello

I'm calling

TD.TransactionID := 1;
TD.IsolationLevel := xilREADCOMMITTED;
SqlConnection.StartTransaction(TD);

against MSSQL 2000 with dbxsda driver, but in Profiler nothing happens after that call. The old BDE TDatabase.StartTransaction call works as expected.

OS: Windows XP Pro
Delphi: 7.0 with service pack (build 8.1)

Thanks in advance,
Marcos

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: SQLConnection.StartTransaction does nothing

Post by Ikar » Thu 11 Nov 2004 09:37

It is an optimization from OLE DB side. Actually a transaction is started on
executing the first query in this connection.

Guest

Post by Guest » Thu 11 Nov 2004 16:08

There's no workaround? I need to manually start a transaction in several places. What's happening is that every call to applyupdates in my transaction is generating its own begin trans and commit, thus the operation isn't atomic anymore...
It's the expected behavior of cds.ApplyUpdates, but only when there's not another transaction opened.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 12 Nov 2004 09:48

This optimization doesn't influence on essence of the transaction. All queries
between StartTransaction and Commit will be within the same context.
For example, for the next code

Code: Select all

TD.TransactionID := 1;
TD.IsolationLevel := xilREADCOMMITTED;
SQLConnection.StartTransaction(TD);

ClientDataSet.ApplyUpdates(0);
SQLQuery1.SQL.Text := 'update "SDAC_BLOB"  set "Name" = ''ssss'' where UID =111';
SQLQuery1.ExecSQL();

SQLConnection.Commit(TD);
before execution of SQLConnection.Commit(TD) data from ClientDataSet will not be committed.

Post Reply