Visual Studio .NET - timeout before data is returned from the database

Asked By carmen vacar on 19-Jan-04 02:25 PM
Hello,

I am writing an ASP.NET web app using C#. All is well when the queries I'm running against a SQL Server database return quickly. However, for lengthier queries I get the following error:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 

When the same query is executed from inside the database all is fine. 

I checked the connection time setting for the application and it looks like it is 15 seconds:

int conTimeOutSec = cnOligo.ConnectionTimeout; 

RETURNS conTimeOutSec=15

I'm sure this is some .NET default as I'm not setting the connection timeout anywhere and the database server timeouts are set to in excess of 20 minutes.

Any ideas how I can increase the timeout setting? I need to gather the data returned from the database into a DataSet and not just populate a grid with it - so I think that using a SqlCommand and then using command.ExecuteReader won't work. Or will it?

Any help would be greatly appreciated.

cvacar

You will probably need to post both the - Asked By Peter Bromberg on 19-Jan-04 06:56 PM

database calling code, and the sql or stored procedure that it runs.

However, there are 2 timeouts you should be aware of:

1) connection timeout. This can only be specified in the Connection String (e.g., ";Connection Timeout=60;")
2) command timeout. This can be set as a property of the command instance 
(e.g., cmd.CommandTimeout=90)

test - Asked By carmen vacar on 21-Jan-04 01:34 PM

test

It was the Command timeout! - Asked By carmen vacar on 21-Jan-04 01:36 PM

Thanks, Peter.

I tried fiddling with both the Connection TimeOut and the Command TimeOut settings. It was the Command that was timing out.

Thanks.