Hello,
after the Update from UniDac 4.5.9 to 6.4.16 I cannot use the same UniConnection in EXE und DLL.
In my DLLs I use TUniConnection.AssignConnect
This works fine in UniDac 4.5.9. The Error-Message in 6.4.16 is:
"Can't perform operation on active transaction".
I'm sure there is no active transaction.
So I made some Tests:
After MyUniConnection.Connect the property MyUniConnection.InTransaction is false.
Then I opened a small table. MyUniTable.Open sets MyUniConnection.InTransaction = true.
Another example: UniConnection1.GetTableNames sets MyUniConnection.InTransaction = true.
How can this be? Only Table.Open or GetTablenames cannot start a transaction.
What shall I do?
Kind regards,
Gerd Brinkmann
invent GmbH
UniDac 6.4.16: Problem with InTransaction and AssignConnect
Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect
InterBase/Firebird requires an active transaction for any operation with data, even for opening dataset. Therefore, when calling TUniQuery.Open or TUniConnection.GetTableNames, it is verified if a transaction associated with it is running and, if it is not so - it is automatically run. In your example dataset uses a default transaction TUniConnection, therefore when attempting to call the Connection.StartTransaction method, you get the "Can't perform operation on active transaction" error, because when opening dataset the transaction has already started.
To solve the issue you can use the following advice:
- use for dataset a separate transaction, not a default transaction TUniConnection;
- use for data modification UpdateTransaction.
The point is, that in UniDAC since version 5.0.1 we added the DefaultTransaction transaction property. All datasets that use the TUniConnection component, use its DefaultTransaction for all operations under data. We added the property because a lot of our users asked us to do it.
In earlier UniDAC versions, all the datasets that used TUniConnection, used implicitly created internal transaction. This transaction always remained open, and it was not possible to control it.
In order to provide backward compatibility with older UniDAC versions, we added the OldTransactionBehaviour global variable declared in "Uni.pas". The default variable value is "False". So, if you want to have old behaviour, you should set the variable to "True".
To solve the issue you can use the following advice:
- use for dataset a separate transaction, not a default transaction TUniConnection;
- use for data modification UpdateTransaction.
The point is, that in UniDAC since version 5.0.1 we added the DefaultTransaction transaction property. All datasets that use the TUniConnection component, use its DefaultTransaction for all operations under data. We added the property because a lot of our users asked us to do it.
In earlier UniDAC versions, all the datasets that used TUniConnection, used implicitly created internal transaction. This transaction always remained open, and it was not possible to control it.
In order to provide backward compatibility with older UniDAC versions, we added the OldTransactionBehaviour global variable declared in "Uni.pas". The default variable value is "False". So, if you want to have old behaviour, you should set the variable to "True".
Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect
Hello Viktor,
thanks for this information. Unfortunately that won't solve my case with AssignConnect.
That works.
That gives an error.
So, how can I use AssignConnect?
Kind regards,
Gerd Brinkmann
invent GmbH
thanks for this information. Unfortunately that won't solve my case with AssignConnect.
Code: Select all
MyUniConnection1.Connect;
MyUniConnection2.AssignConnect(MyUniConection1);
Code: Select all
MyUniConnection1.Connect;
MyUniConnection1.GetTableNames (...);
MyUniConnection2.AssignConnect(MyUniConection1);
So, how can I use AssignConnect?
Kind regards,
Gerd Brinkmann
invent GmbH
Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect
Thank you for the information. We have reproduced the issue and investigation is in progress. We will inform you when we have any results.
Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect
Thanks. I hope you will find a solution.
Until then I made a workaround:
It's not nice, but it works.
Kind regards,
Gerd Brinkmann
invent GmbH
Until then I made a workaround:
Code: Select all
MyUniConnection1.Connect;
MyUniConnectionTemp.AssignConnect(MyUniConection1);
MyUniConnection1.GetTableNames (...);
MyUniConnection2.AssignConnect(MyUniConectionTemp);
Kind regards,
Gerd Brinkmann
invent GmbH
Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect
We have fixed this issue, the fix will be included in the next UniDAC build.