What is the difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout?

Dhanapal picture Dhanapal · May 11, 2009 · Viewed 67.1k times · Source

Is there any difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout in .NET?

Answer

Jon Skeet picture Jon Skeet · May 11, 2009

Yes. CommandTimeout is how long a single command can take to complete. ConnectionTimeout is how long it can take to establish a connection to the server to start with.

For instance, you may be executing relatively long-running queries - it's perfectly okay for them to take 10 minutes to complete, but if it took 10 minutes to make the connection to start with, you'd know that something was badly wrong.