Delphi connection sql database how to determine whether the connection is successful it

After all the attributes are set, I Button in ADOConnection1.Connected: = True; even so, followed by how to determine whether the connection is successful it?
Inquiries about the data to try? There are more direct way?

-----------

if ADOConnection1.Connected then successful connection

2 may be connected to write a function, try to connect the data to a database table, a successful return value is connected.

3, as follows:

var Con: Boolean;
   the try 
    DataModule1.ADOCon.Connected: = False; 
    DataModule1.ADOCon.ConnectionString: = the ConnectionString; 
    DataModule1.ADOCon.Connected: = True; 
    Con: = True; 
    StatusBar1.Panels [ 0 ] .Text: = ' Data connection succeeded! ' ;
   The except 
    Con: = False; 
    StatusBar1.Panels [ 0 ] .Text: = ' connection data failed ...... ' ;
   End ;

(1) is connected by a Con determination
(2) StatusBar1 shows whether the connection is successful.

DataModule1 with just a good habit, right? No it is not nothing different

Guess you like

Origin www.cnblogs.com/jijm123/p/11304932.html