?
Solved

Timeout expired: error '80040e31'

Posted on 2001-09-17
4
Medium Priority
?
1,804 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 150 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

589 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