SQL application connection failed

Source: Internet
Author: User
Tags odbc sql server driver odbc sql server driver

Faults:

In the application, we will also encounter similar error messages, such:
Microsoft ole db Provider for ODBC Drivers error '20140901'
[Microsoft] [odbc SQL Server Driver] timeout expired


Solution:

A. If A Connection timeout error occurs, you can modify the timeout settings of the Connection object in the program and then open the Connection. For example:

The code is as follows: Copy code
<%
Set Conn = Server. CreateObject ("ADODB. Connection ")
DSNtest = "DRIVER = {SQL Server}; SERVER = ServerName; UID = USER; PWD = password; DATABASE = mydatabase"
Conn. Properties ("Connect Timeout") = 15' in seconds, 0 indicates no limit
Conn. open DSNtest
%>


B. If a query timeout error occurs, you can modify the timeout settings of The Recordset object in the program and then open the result set. For example:

The code is as follows: Copy code
Dim cn As New ADODB. Connection
Dim rs As ADODB. Recordset
...
Cmd1 = txtQuery. Text
Set rs = New ADODB. Recordset
Rs. Properties ("Command Time Out") = 300
'The unit is second. If it is set to 0, there is no limit.
Rs. Open cmd1, cn
Rs. MoveFirst

...

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.