live-chat
Email

Intellect Connect

How do I Increase the Timeout Value in SQL?

There are two places where you can specify Timeout settings in SQL. One being during the actual initialization of the connection string, called “ConnectionTimeout“. This will effect any query made under this database connection string. The other option would be to specify it during the actual query command, called “CommandTimeout“.

conn.ConnectionTimeout

Where conn is an ADODB.Connection object that is not yet open, the connectionTimeout property will indicate the amount of time, in seconds, to wait for an ASP application to initially connect to the data source. The default is 15 seconds; to override the default, use syntax as follows:

<%
Set conn = CreateObject("ADODB.Connection")
conn.<strong>ConnectionTimeout</strong> = 120
conn.Open <connectionString>
%>

CommandTimeout tells the server how long to wait, in seconds, for completion of any command sent to the data source. This value is editable before and after the connection has been opened. The default is 30 seconds, but you can override it like this:

<%
Set conn = CreateObject("ADODB.Connection")
conn.Open <connectionString>
conn.<strong>CommandTimeout</strong> = 120
%>

Note that you can also apply a commandTimeout value to a command object, and it will behave independent of the commandTimeout value associated with the connection object. So for specific stored procedures or other commands being executed explicitly through the ADODB.Command object, you could have a longer timeout than that of the connection object. The syntax for the command object is almost identical:

<%
Set cmd = CreateObject("ADODB.Command")
cmd.<strong>CommandTimeout</strong> = 120
%>

Interested in letting our experts solve your IT problems for you? Get a free, no-obligations consultation with one of our experts today!
Chat Now!, Contact Us , Or call us at (855) 850-HOST

footer-logos