Solved

Timeout expired: error '80040e31'

Posted on 2001-09-17
4
1,667 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

778 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