Solved

Timeout expired: error '80040e31'

Posted on 2001-09-17
4
1,674 Views
Last Modified: 2011-10-03
I have an ASP page that continually is bombing with "Microsoft OLE DB Provider for SQL Server, error '80040e31', Timeout expired".

I'm using the following commands:

 Dim conn  
 Dim oRS
 Set conn = Server.CreateObject("ADODB.Connection")
 conn.ConnectionTimeout = 0  ' also tried 10000
 conn.Open sDSN
 set oRS = Server.CreateObject("ADODB.RecordSet")
 oRS.ActiveConnection = conn
 oRS.open sSQL


 I've also used the "Server.ScriptTimeout = XXX" command to no avail.
0
Comment
Question by:EasyAim
  • 2
4 Comments
 
LVL 1

Expert Comment

by:dmeili
ID: 6488099
Have you tried setting the Conn.CommandTimeout as well?
0
 
LVL 5

Expert Comment

by:dredge
ID: 6488277
the issue you are having is not with the connection object itself, but with the SQL commands you are sending.

there are many items to consider, but two important ones would be:

how many records are in the table you are searching?
what is the exact SQL code you are sending (the sSQL variable)?
0
 

Author Comment

by:EasyAim
ID: 6488642
Well, Mr. dredge, I think you are on the right track.  After cut-and-pasting my SQL statement into "Query Analyzer" (which I should have done first of course) I realized I had an orphaned reference to a table which was causing my statement to peruse every record unnecessarily in a big table.

After fixing my SQL statement everything worked fine.

HOWEVER, lets pretend that my SQL statement was actually optimized but takes a very long time to run...  how would I get my ASP page to patiently wait for results?
0
 
LVL 5

Accepted Solution

by:
dredge earned 50 total points
ID: 6490344
if your sql statement was fine, and it was taking forever, there are a number of things that you can do.

the previous posts were on the right track for a very basic form of waiting... however, you should look at optimizing instead of just waiting.

this includes managing the Indexes on your tables, creating Stored Procedures to execute SQL statements instead of using inline SQL code directly from ASP (this alone can speed up your processing by 10 to 20 times), making sure to open/close the proper recordset types in ASP, and knowing when to use Client or Server side cursors in ADO (server side keeps the records on the server until they are used, client side loads all of the records onto the machine that made the call to SQL server).

these are just the beginning of optimizing SQL server, too. there's so much more out there...
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

808 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