John Porter
asked on
Increasing the Timeout Value for a SQL SERVER 2005 connection
Hello Experts,
I am calling a Stored Procedure from a C# application. It works fine mostly but the connection times out when the dataset gets large.
Is there a way to reset the default timeout value to increase the time before the connection times out in SQL Server 2005?
Thanks!
I am calling a Stored Procedure from a C# application. It works fine mostly but the connection times out when the dataset gets large.
Is there a way to reset the default timeout value to increase the time before the connection times out in SQL Server 2005?
Thanks!
ASKER
Thanks Fernando,
I will give this a try. My situatuin is #2 (SqlCommand.CommandTimeout = NumberOfSeconds;
). Is it better to put it before or after the executing the command?
I will give this a try. My situatuin is #2 (SqlCommand.CommandTimeout
). Is it better to put it before or after the executing the command?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! Thanks
Not a problem, glad I was able to help. ;=)
There are two timeouts and I am not sure which one you are talking about.
The first of the two is:
The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.
This timeout is set in the connection string and its value is in seconds, the default is set to 15 seconds. The value is, Connect Timeout = NumberOfSeconds; or, Connection Timeout = NumberOfSeconds; either way will do.
The second of the two is when the connection has been made and you have executed a command:
Gets or sets the wait time before terminating the attempt to execute a command and generating an error. The default timeout is 30 seconds.
SqlCommand.CommandTimeout = NumberOfSeconds;
Where SqlCommand is the instance variable of the SQL Command.
Fernando