I'm trying to convert my application from anydac/firedac to unidac and i'm hitting a serious problem when closing a transaction.
I'm using a TUniQuery to display data (as a sort of memory dataset) and in a couple of steps further i'm using the same connection to retrieve a record via a second query (see code). While committing the transaction of the 2e query the memorydataset is also closed which is a total different behaviour than AnyDac. It will cause all kind of problems with our software.
Demo code:
Code: Select all
OldTransactionBehaviour := True; //The new transactions system does really not work for me (way to much work)..
displaydataset := TUniQuery.Create(nil);
displaydataset.Connection := MyConnection;
displaydataset.Sql.text := 'select * from whatever');
displaydataset.Open;
connection.StartTransaction;
lookupQuery := TUniQuery.Create(nil);
lookupQuery.Connection := MyConnection;
lookupQuery.Sql.text := 'select * from whatever');
lookupQuery.Open;
..something
connection.CommitTransaction; // <-- This closes the displaydataset and lookupquery as well (didn't expect that)..
Removing the offending line makes does make my code work, but what kind of problems a'm i introducting with this change? And what is the reason of this behaviour, whu is a second query spontaniously closed when commiting a connection (at least I think this is weird behaviour). Is this a bug??
Code: Select all
procedure TDATransaction.CloseDataSets;
var
i,j: Integer;
begin
for i := 0 to FConnections.Count - 1 do begin
if not FConnections[i].IsMultipleTransactionsSupported then
continue;
for j := 0 to FConnections[i].DataSetCount - 1 do
if FConnections[i].DataSets[j] is TCustomDADataSet then begin
//if TCustomDADataSet(FConnections[i].DataSets[j]).UsedTransaction = Self then
//TCustomDADataSet(FConnections[i].DataSets[j]).ConnectChange(FConnections[i], False);//We can't use SendConectEvent(False)
end
else
if FConnections[i].DataSets[j] is TDAMetaData then begin
if TDAMetaData(FConnections[i].DataSets[j]).UsedTransaction = Self then
TDAMetaData(FConnections[i].DataSets[j]).ConnectChange(FConnections[i], False);//We can't use SendConectEvent(False)
end;
for j := 0 to TCustomDAConnection(FConnections[i]).FSQLs.Count - 1 do
if TCustomDASQL(FConnections[i].FSQLs[j]).UsedTransaction = Self then
TCustomDASQL(TCustomDAConnection(FConnections[i]).FSQLs[j]).ConnectChange(FConnections[i], False);
end;
end;
Marius