Connection timeout for SQL server

zachary picture zachary · Nov 29, 2010 · Viewed 289.6k times · Source

Can I increase the timeout by modifying the connection string in the web.config?

Answer

Darin Dimitrov picture Darin Dimitrov · Nov 29, 2010

Yes, you could append ;Connection Timeout=30 to your connection string and specify the value you wish.

The timeout value set in the Connection Timeout property is a time expressed in seconds. If this property isn't set, the timeout value for the connection is the default value (15 seconds).

Moreover, setting the timeout value to 0, you are specifying that your attempt to connect waits an infinite time. As described in the documentation, this is something that you shouldn't set in your connection string:

A value of 0 indicates no limit, and should be avoided in a ConnectionString because an attempt to connect waits indefinitely.