Solved

Timeout expired: error '80040e31'

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SLQ View not updating 10 47
Word Template Mail merge with vb.net 4 40
Complex SQL 10 34
Test a query 23 19
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 …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now