Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Timeout expired: error '80040e31'

Posted on 2001-09-17
4
Medium Priority
?
1,712 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

715 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