Solved

Increasing the Timeout Value for a SQL SERVER 2005 connection

Posted on 2008-06-23
5
945 Views
Last Modified: 2013-12-16
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!
0
Comment
Question by:Saxitalis
  • 3
  • 2
5 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 21852265
Hi Saxitalis;

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

 

0
 

Author Comment

by:Saxitalis
ID: 21852320
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?

0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 21852416
Needs to be before executing the command.
0
 

Author Closing Comment

by:Saxitalis
ID: 31470024
Perfect! Thanks
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 21880630
Not a problem, glad I was able to help. ;=)
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now