Solved

Classic ASP page - DB connection Timeout issue

Posted on 2011-09-30
4
1,358 Views
Last Modified: 2012-06-22
Hi,
I am maintaining some old ASP code that I did not write. I am a programmer and a DB admin but I am not very familiar with ASP.
Here is the situation:
I have a web page that runs a query to SQL 2005. If the query returns 5 or 10 records it's fine. If it returns a large number, (1000), then I get the following error message on my browser:

----
Microsoft OLE DB Provider for ODBC Drivers error '80040e31'
[Microsoft][ODBC SQL Server Driver]Timeout expired
/utility/search_script.asp, line 201
-----
LINE 201 is below...

Set UserNames = Server.Createobject("ADODB.Recordset")
LINE 201 --> UserNames.Open sqlq, Connect  ,adopenstatic, adlockreadonly

If I run the same query in a SQL command line I get no problems returning the data.
So my question is:
Is the timeout issue an ASP script problem or an ODBC problem?
Suggestions please on how to fix this.  The entire script is about 400 lines long, which is why I didn't post the whole thing. But I can post additional pieces of it if need be.

Thanks!



0
Comment
Question by:nachtmsk
  • 2
4 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 36892629
you try something like
<%
    Server.ScriptTimeout = 180
%>

in asp code
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 36892709
The error you are getting is a sql command timeout.
By default the command timeout is 30 secs if your query is going to take longer than 30 seconds you will need to increase it by setting the CommandTimeOut property of your command object.
Something like :

myCommand.CommandTimeout = 60

See for further info : http://vyaskn.tripod.com/watch_your_timeouts.htm

If you want further help post some of the code above line 201 where the command and connection objects are created.

0
 

Author Comment

by:nachtmsk
ID: 36893345
Thanks for the comments.
In my case, Jacko72's answer was correct. I looked at the sql statement that was being passed. It was different then I thought it was. It was joining on 4 tables. Anyway, the SQL is what was timing out. Thanks!
M
0
 

Author Closing Comment

by:nachtmsk
ID: 36893346
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

679 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