Delphi IBX "Lost Connection" Code

Most of my database applications have a generic IBQuery component and associated IBTransaction to perform queries. This page presents code examples that allow your program to keep running after a temporary database server connection problem.

To test basic functionality

(My actual test code was much more complicated than this, and many more scenarios were tested ... but those are the basic steps.)

All the queries used the same IBQuery component.

The original code below worked fine until the server was restarted ... then it would only generate errors. The patched code (with lots of try..except blocks) runs without any errors.

I do not know if better code can be written (I always assume that it can), but as far as I know, it works.

Note: If you have the wrong IBX version, your Delphi program simply crashes and Windows terminates it. You must have a recent version for the following code to work.

Original code | Patched code | HandleIBErrors Notes


Original code


Patched code


HandleIBErrors Notes

The HandleIBErrors method is a little complicated - I would love to see a better solution (actually, a REAL solution ... I consider this to be a kludge).


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Databases / Delphi / IBX_LC_Code.html