<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hi all,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">
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?</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks in advance</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">
<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Richard</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style><div class="gmail_default" style>
<font face="arial, helvetica, sans-serif"> fOnline := True;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> try</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> if fIBConnection.Connected then</font></div>
<div class="gmail_default" style><font face="arial, helvetica, sans-serif"> Exit;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default" style>
<span style="font-family:arial,helvetica,sans-serif"> with fIBConnection do</span><br></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> begin</font></div><div class="gmail_default" style>
<font face="arial, helvetica, sans-serif"> HostName := 'hostname';</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> DatabaseName := 'location';</font></div>
<div class="gmail_default" style><font face="arial, helvetica, sans-serif"> UserName := 'username';</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> Password := 'password';</font></div>
<div class="gmail_default" style><font face="arial, helvetica, sans-serif"> end;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> end;</font></div><div class="gmail_default" style>
<br></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> fIBConnection.Transaction := fSQLTransaction;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"><br>
</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> with fSQLQuery do</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> begin</font></div>
<div class="gmail_default" style><font face="arial, helvetica, sans-serif"> DataBase := fIBConnection;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> Transaction := fSQLTransaction;</font></div>
<div class="gmail_default" style><font face="arial, helvetica, sans-serif"> end;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default" style>
<font face="arial, helvetica, sans-serif"> //Finally switch on connection</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> fSQLTransaction.DataBase := fIBConnection;</font></div>
<div class="gmail_default" style><font face="arial, helvetica, sans-serif"> fIBConnection.Connected := True;</font></div><div class="gmail_default" style><span style="font-family:arial,helvetica,sans-serif"> except</span><br>
</div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> fOnline := False;</font></div><div class="gmail_default" style><font face="arial, helvetica, sans-serif"> end;</font></div><div style="font-family:arial,helvetica,sans-serif">
<br></div></div></div>