Hello,
I have an asp page that uses odbc to connect to a sql svr db. The db is quite large and the page times out due to an ODBC timeout. Can someone tell me how to change the odbc timeout property?
strcon = "Driver={SQL Server};Server=" & ComputerName & ";Uid=" & UserID & ";Pwd=" & Password & ";Database=mydb"
if Session("cn".state = 1 then Session("cn".close
Session("cn".Open strcon
Select Case Session("cn".State
Case adStateOpen
Response.Redirect("search.asp"
Case Else
Response.Redirect("error_main.asp"
End Select
end if
then, the query is:
set RS = server.CreateObject("adodb.recordset"
RS.Open sql, Session("cn", 3, 3, 1
Please note:
i've stepped into this code for bugfix and i have to change the connection to use a DSN provided by the user, and to be db independent.
I am not sure about ODBC time out, I always use the native ADO providers - more efficient, but be aware the ADO connection and command objects also have a timeout setting. Maybe one of these, in your case, the connection is timing out and the error message is not correct.
'-set the connection timeout
strcon.CommandTimeOut = 500 '- this is seconds
instead of the default of 30 seconds
Timing out often indicates that the query is inefficient. You may need to optimize the query that gets the recordset to reduce the time it spends trying to execute it. Is the table indexed on the field(s) you are searching on?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.