I usually use ADO to connect Delphi applications, which involves several phenomena:
1. Normal connection. After the program starts, it connects to the database. If the connection conditions are normal, the software will soon be connected successfully. This is not necessary;
2. Connection Failed. This includes abnormal database servers and incorrect application connection parameters. During the connection process, the interface may be suspended, and the duration is long (I set the timeout time as if it didn't work, such as adoconn. connectiontimeout: = 10 ;). The pop-up dialog box shows the connection error and the error message is returned. This is a headache for me;
3. During the connection to the database, if the physical connection is disconnected, the application will not detect it and must be handled manually. After the software submits select, insert, update, delete, and other operations to the database, the application will also see the situation described above. The following code is used to process connection Detection:
The physical connection is disconnected due to network instability. tadoconnection. Connected is true. Only when the database is called cannot be connected to the database.
Procedure tdmdbconn. adoconnexecutecomplete (connection: tadoconnection;
Recordsaffected: integer; const error: error;
VaR eventstatus: teventstatus; const command: _ command;
Const recordset: _ recordset );
VaR
Errno: integer;
Errdetail, connstr: widestring;
Begin
If error <> nil then
Begin
Errno: = Error. number;
Errdetail: = Error. description;
Connstr: = adoconn. connectionstring;
If pos ('Connection failed', errdetail)> 0 then
Begin
If gagentsysparam. serverconndb = 1 then
Begin
Adoconn. close;
End;
End;
End;
End;
1. As long as the server is abnormal, it will definitely be suspended for a long time.
2. If SQL Server cannot be found due to an IP configuration error, the server is suspended for a long time. If the name, user name, and password of other databases are incorrect, the server can be found .. Quick Match
Therefore, there is a false death phenomenon, and the duration is relatively long, it is absolutely unable to find the sqlserver server, and thus repeated attempts to link the sqlserver Server Based on the ADO Link Mechanism to generate a long period of false death phenomenon and frmmain. adoconnection1.keepconnection attribute unrelated