Problem with re-connecting to Firebird database

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
andy_bri
Posts: 19
Joined: Fri 02 Oct 2009 12:36

Problem with re-connecting to Firebird database

Post by andy_bri » Wed 27 Jul 2011 18:20

I use UniDAC to work with Firebird database. If a connection is lost (weak signal in wireless network or just cable removed for a moment) I can not reconnect to database.

For example:
1. I remove cable
2. I try to open UniQuery.
Now instead of OnConnectionLost I receive exception "Can't perform operation on a closed dataset" (TUniConnection.Options.LocailFailover set to True and DisconnectMode also set to True, but all combinations tested).

3. I stick the cable to computer again and press Ok.
In the program (exception handling) I try to Disconnect and Connect again, because UniConnection flag is still set to True.
4. When I try again to OpenQuery I receive a message:

Can't perform operation on active transaction.

I tried to manually StartTransaction, Rollback, Commit and so on.
The only other result I get is a message:

invalid transaction handle (expecting explicit transaction start)

How to reconnect to the database after temporary network problems?

AndreyZ

Post by AndreyZ » Thu 28 Jul 2011 11:28

Hello,

Such problem can occur if you establish connection and start transaction explicitly. The point is that every explicit operation must be finished explicitly. Therefore, if you open connection explicitly, you should close it explicitly, and if you start transaction explicitly, you should end it explicitly. To avoid this problem, you should let UniDAC handle connection lost situations by not opening connections and starting transactions explicitly. The UniConnection.LocalFailover and UniConnection.DisconnectedMode properties must be set to True.

Post Reply