Subject Re: [IBO] database reconnect techniques
Author Carlos E. Tré
Hi

> 1. Automatically check if database connection has been dropped due to
> network connectivity or other issues

I've asked the same question a while back and from the tips I got, I started as follows,
but, please, not that this app is still in development, and this procedure hasn't gone
through real file tests yet, so take it as a starting point


1) write an OnError event handler for the TIB_Connection component

if (ERRCODE=isc_lost_db_connection) then
ReconnectAPP();

3) coded the ReconnectAPP procedure as follows

procedure T_VFI_MasterDM.ReconnectAPP;
var
Atmpts: Integer;
begin
Atmpts := 0;
while (
(Atmpts<FMaxRcnct)
and
(cnxAPP.Connected)
)
do begin
try
Inc(Atmpts);
cnxAPP.Disconnect();
except
Sleep(FRcnctWait);
end;
end; // while
if (cnxAPP.Connected) then
raise <Disconnect Failed>;
Atmpts := 0;
while (
(Atmpts<FMaxRcnct)
and
(not cnxAPP.Connected)
)
do begin
try
Inc(Atmpts);
cnxAPP.Connect();
except
Sleep(FRcnctWait);
end;
end; // while

// if still disconnected then alert user or other desired behaviour

end;


--
Best,
Carlos