Page 1 of 1
SQLConnection.StartTransaction does nothing
Posted: Wed 10 Nov 2004 19:34
by Marcos
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
Re: SQLConnection.StartTransaction does nothing
Posted: Thu 11 Nov 2004 09:37
by Ikar
It is an optimization from OLE DB side. Actually a transaction is started on
executing the first query in this connection.
Posted: Thu 11 Nov 2004 16:08
by Guest
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.
Posted: Fri 12 Nov 2004 09:48
by Ikar
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.