Tuesday, February 14, 2012

Command Timeout in web config

I'm having timeout issues with a few stored procedures which do calculations and take a while to return data (like 2-3 minutes).

I'm getting timeouts when I try to run them in my asp.net page.

From my research it seems that I need to increase the Command Timeout setting. I'm storing my connection string in my web.config file and I can't seeem to get the syntax correct for increasing the command timeout setting.

Can someone show my how it's done.

My connection string (from web.config):


<appSettings>
<add key="DataGold" value="server=localhost;uid=datauser;pwd=qu3ry;database=DataGold" />
</appSettings>

TIA.If you are working with command object, then you can increase timeout for it by

myCommand.CommandTimeout = Time

Or if Dataadapter using command object then it wll go as

DataAdapter.SelectCommand.CommandTimeout = Time

Difference between command & connection Timeouts:
CommandTimeout Property Gets or sets the wait time before terminating the attempt to execute a command and generating an error. The default is 30 seconds.

ConnectionTimeout Property Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error. The default value is 15 seconds.

No comments:

Post a Comment