Physical connection disconnection caused by network instability of a single adoconnection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.