[Lazarus] Handling Firebird connection
Richard Mace
richard.mace at gmail.com
Mon Aug 25 09:32:41 CEST 2014
Hi all,
I have the following code that I use to connect to a Firebird database,
which works fine, however, if the Firebird server becomes unavailable,
fIBConnection.Connected always returns true. What's the best way of
checking to make sure that the Firebird server is still available before I
attempt to connect to the database?
Thanks in advance
Richard
fOnline := True;
try
if fIBConnection.Connected then
Exit;
with fIBConnection do
begin
HostName := 'hostname';
DatabaseName := 'location';
UserName := 'username';
Password := 'password';
end;
end;
fIBConnection.Transaction := fSQLTransaction;
with fSQLQuery do
begin
DataBase := fIBConnection;
Transaction := fSQLTransaction;
end;
//Finally switch on connection
fSQLTransaction.DataBase := fIBConnection;
fIBConnection.Connected := True;
except
fOnline := False;
end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140825/c2e44f11/attachment-0002.html>
More information about the Lazarus
mailing list