Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "Connect Timeout" in sql server connection string?

Tags:

sql

sql-server

I have the following connection string(get from a property of sql server):

Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\myUser\Desktop\adoBanche\Banche\bin\Debug\banche.mdf;Integrated Security=True;Connect Timeout=30 

I don't understand what mean Timeout=30. Someone could explain what means?

like image 815
Tinwor Avatar asked Nov 22 '13 10:11

Tinwor


People also ask

How do you resolve connection timeout in SQL?

If you encounter a connection-timeout error, follow the steps: Increase the connection-timeout parameter. If you use an application to connect to SQL Server, increase the relevant connection-timeout parameter values and check whether the connection eventually succeeds.

What is connection timeout?

Connection timeout is a common error that occurs whenever the client is waiting for too long before getting a response from any server (for API calls or browser requesting pages).

What is SQL Server timeout?

The remote query timeout option specifies how long, in seconds, a remote operation can take before SQL Server times out. The default value for this option is 600, which is a 10-minute wait.


1 Answers

That is the timeout to create the connection, NOT a timeout for commands executed over that connection.

See for instance http://www.connectionstrings.com/all-sql-server-connection-string-keywords/ (note that the property is "Connect Timeout" (or "Connection Timeout"), not just "Timeout")


From the comments:

It is not possible to set the command timeout through the connection string. However, the SqlCommand has a CommandTimeout property (derived from DbCommand) where you can set a timeout (in seconds) per command.

Do note that when you loop over query results with Read(), the timeout is reset on every read. The timeout is for each network request, not for the total connection.

like image 74
Hans Kesting Avatar answered Oct 08 '22 12:10

Hans Kesting