SOLVED:SqlException (0x80131904): Timeout expired.

We have a ASP 2.0 website that has been running since Dec/2009, without any issues on Windows 2003 R2, and Microsoft SQL Server 2005 - 9.00.5000.00 (X64)
(Build 3790: Service Pack 2).
Starting last week, the site now errors out with the following error.

Exception Details:
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Re: SOLVED:SqlException (0x80131904): Timeout expired.

Maybe your database now has so much data that it is legitimately timing out?

Mark all posts that give the desired result the answer. If you only mark the last that gave you clarification because you misread an earlier post others will be confused. Some of us are here to help others and our point to post ratio matters.

Re: SOLVED:SqlException (0x80131904): Timeout expired.

I had same issue some years ago.
And had to reconsider/refactor my queries before default page (a DashBoard).
Suggest you, in mean time, set Timeout on Database Connection String and if using Linq DatabaseContext set CommandTimeout property on initialization, just to get some more time while you review what can be done with query, indexes, or even in default page.

Re: SOLVED:SqlException (0x80131904): Timeout expired.

You can try to debug or implement log in your application to find and trace which code causes this exception.

The exception can come because of query timeout, connection timeout etc.
This blog explained the possible causes of this exception, you can refer to it.

Besides, as you said, the application is running for many years, too many data might be stored in your database. If possible, you can try to archive&reomve old data from current table into the Archive table (or in other database), which should be able to
improve the performance.

With Regards,

Fei Han

MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.

Re: SOLVED:SqlException (0x80131904): Timeout expired.

At the moment I'm unable to remove the data from production. I finally was able to rebuild the old website in Visual Studio. I setup the debugger to stop at all the SQL calls on the client side, but when I step threw the code. It just goes threw the
Page_Load and Page.IsPostBack methods, then the browser opens, and its just a white screen, then I get the error. I turned on my trace, and I get the following trace info below.

3. One of the SQL statements takes 220 secs to run in my dev environment, and takes 30-65+ secs in production. Its the longest running query of the four.

Since the SQL statements are ran at the server, within the ASPX part of the code on the server side. How can I debug this part of the code?
What is the default timeout in the SelectCommand on the ASPX default page, if my database is set to 600 sec on query?
Is there a way for me to increase the timeout without any code change here?

Not sure if the db side value is used. It might be overriden client side maybe and anyway if it doesn't seems the request should really take that long it is likely better to first understand why it is slow and to increase the timeout as a last resort.

Re: SOLVED:SqlException (0x80131904): Timeout expired.

The issue appears to be resolved! The table that had over 145 million records, didn't have a good index on it. Once I created a decent index, the default page displayed without any issue, and also displayed in seconds!

Everyone is happy, and shocked at how fast it runs now. I plan on working with the SQL DBA, to really give the site a good performance upgrade by creating good indexes.