Proper way to handle a database connection lost

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Proper way to handle a database connection lost

Post by josecarlos » Fri 15 Mar 2013 11:43

My application open the connection on the start and keeps it opened till the application, I think all desktop application working this way.

I have a customer that I am having connection issues, the application lost the database connection, and raises the message "Unable to complete network request to host "SERVER-NAME". Error writing data to the connection".

This happens when the computer client lost internet ( ADSL ) connection.

What is the best approach to handle or fix this.

I am thinking about the OnConnectionLost event and make this:

Code: Select all

procedure TdmSistema.ibDAFConnectionLost(Sender: TObject; Component: TComponent;
  ConnLostCause: TConnLostCause; var RetryMode: TRetryMode);
begin
  RetryMode := rmReconnect;
end;
Is this ok?

Thanks.

AndreyZ

Re: Proper way to handle a database connection lost

Post by AndreyZ » Fri 15 Mar 2013 14:15

Yes, using the OnConnectionLost event handler is a proper way to handle connection losses. For more information, please read the "Working in an Unstable Network" article of the IBDAC documentation.

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Proper way to handle a database connection lost

Post by josecarlos » Sat 16 Mar 2013 16:27

Thanks

AndreyZ

Re: Proper way to handle a database connection lost

Post by AndreyZ » Mon 18 Mar 2013 08:03

Feel free to contact us if you have any further questions about IBDAC.

Post Reply