In Delphi 7, how to quickly determine whether SQL can connect??

Source: Internet
Author: User

In Delphi 7, how to quickly determine whether SQL can connect??
Thank you, everyone!!

With DM do
Begin
conn.connected: = False;
Conn.connectionstring: = connstring;
Try
conn.connected: = True;
Except
Application.messagebox (' Server connect error!! ', Cp_main,mb_oce);
End
End

You're just going to disconnect and reconnect if the SQL service is not turned on or it will be slow.
How to determine whether SQL connection, improve the speed of judgment???

You can set the Adoconnection.connectiontimeout to 1, which will be faster, or you can directly determine whether the SQL service is started (native).

Although the connection time is shortened, you will still find that the connection time is very slow during the test.

The key to this question is how fast do you want it? Second level? Millisecond level?
I think the millisecond level is impossible ...
Second-level words, but also depends on your local response time, server response time, network status, a second can be judged out of good. Want to be faster than impossible ah.
Set the adoconnection.connectiontimeout too small is not good, sometimes because of the server response time and network problems, can be connected for several seconds.

You can use port 1433 to determine whether the SQL service is stopped or linked

In Delphi 7, how to quickly determine whether SQL can connect??

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.