Subject | Re: [IBO] How to reconnect to DB II |
---|---|
Author | Jason Wharton |
Post date | 2004-01-22T14:45:48Z |
> Please how can I reconnect do DB (FB1.5 RC7) when the connection hasroughly
> been lost? Beacuse the TIBODatabase.Connected property remains True, the
> only way is probably to listen to the exception.
>
> I implemented an TIBODatabase.OnError event handler, where it looks
> like this:Do NOT make any calls in the OnError event like Disconnect or Connect.
>
> if ERRCODE = 335544721 then begin
> Disconnect;
> Connect;
> end;
>
>
> This works pretty well except that calling Disconnect displays an
> message box 'Dataset is currently fetching' and you have to
> click 'OK' !!!
> It is necessary to avoid that dialog. I'm also not sure about the value
> 335544721 which has been discovered empiricaly.
That is the wrong place to react to an error.
You should only set flags and most of the time raise an exception or allow
the default exception to be raised.
Jason Wharton
www.ibobjects.com