Best way to handle disconnects

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jimmaguire
Posts: 2
Joined: Wed 27 Feb 2013 19:41

Best way to handle disconnects

Post by jimmaguire » Mon 25 Mar 2013 01:26

I want to handle network disconnects from a central location. I tried the OnConnectionLost event, but it does not get fired when I pull the cable from my router, but BeforeDisconnect does.

I see a TRetryMode in OnConnectionLost, but don't see it in help. What are the possible values?

I also see TConnLostCause, what's that for?

I'd like a list of events and corresponding actions I need to take to allow my app to keep running once a connection is lost and then the user clicks a Dialog to indicate he wants to retry.

AndreyZ

Re: Best way to handle disconnects

Post by AndreyZ » Mon 25 Mar 2013 11:51

To make the OnConnectionLost event handler work, you should set the TIBCConnection.Options.LocalFailover property to True. Note that to use the OnConnectionLost event handler, you should add the MemData unit to the USES clause of your unit.
The OnConnectionLost event occurs only when the following conditions are fulfilled:
- a fatal error occurs (one of the following: network_error = 335544721 , lost_db_connection = 335544741, conn_lost = 335544648);
- there are no opened transactions in a connection that are not ReadOnlyReadCommitted;
- there are no opened and non-fetched datasets;
- there are no explicitly prepared datasets or SQLs.
Please make sure that none of the conditions above is violated.
Both TRetryMode and TConnLostCause enumerations are described in the IBDAC documentation. For more information, please read the IBDAC documentation.

Post Reply