473,782 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timeout Error Question

Hi All. I have a SQL Statement on an ASP page that only returns 4 records. When I run it in SQL Server or Query Analyzer it runs in less than a second. When I run it from my ASP page I get:

Microsoft OLE DB Provider for SQL Server error '80040e31'

Timeout expired

the error line points to the rs.Open sql,con line.

The SQL Statement is:

SELECT DISTINCT CUST_SERVICE.AC CTNO As Acct, CONT_DATE, SALES_REP_NAME, DESCRIP, PROD_TYPE, MODE FROM CUST_SERVICE CROSS JOIN CUSTOMER CROSS JOIN ORDERS WHERE (CUST_SERVICE.A CCTNO NOT IN (SELECT DISTINCT acctno FROM orders WHERE oredertype='Blo wout Print' or oredertype='Pri nt')) AND CONT_DATE BETWEEN '12/23/03'AND'12/24/03' AND SALES_REP_NAME = 'Anne' AND PROD_TYPE = 'P' AND CUSTOMER.BILLST = 'ct' AND ORDERS.orederty pe = 'Print' ORDER BY CUST_SERVICE.AC CTNO

Any ideas what could be causing this? I upped the Server.ScriptTi meout, Con.ConnectionT imeout and comCommand.Comm andTimeout and nothing helps.

Dave
Jul 19 '05
11 7594
Dave,

Don't have any ready samples, but here's one approach (of many):

1. Set Response.Buffer =True. Display a DIV with "Working on the query..."
message.
2. Use the adAsyncExecute option of the Connection.Exec ute to execute your
query.
3. Loop to find out if the Connection.Stat e is adStateExecutin g, loop until
this changes.
4. While in the loop, check to see if the client is still connected
(IsClientConnec ted of Request object). If not, do a Connection.Canc el to
cancel the query. At the same time, write out something back to the
Response, and flush it. This lets the browser know the server is
responsive.
5. Once the Connection.Stat e changes, write out a Javascript to hide the
DIV, and do a Response.Flush
6. Display the results.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"David Berry" <db****@mvps.or g> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi Manohar,

Thanks! That works now, although it still takes a long time to bring the
page up. I didn't notice I had the lines reversed.

As for "query the database asynchronously, and poll it to see if the results have been returned. "

Unfortunately I don't know how you do that. Do you have a sample? Also, the query is being dynamically built based on what they enter into 5 search
criteria fields and I need to do it that way. I'd prefer to use a Stored
Procedure but I have no access to the actual SQL Server box (just a backup
copy locally) and they don't want me creating any Stored Procedures (no idea why).

Dave

"Manohar Kamath [MVP]" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:Oq******** ******@TK2MSFTN GP10.phx.gbl...
Dave,

Swap the lines to:

cn.ConnectionTi meout = 6000
cn.Open "file name=e:\micro.u dl"

Actually, the connection timeout won't help you much here, since the
connection seems to be fine, and time out happens when query is issued.

Also, move the line Server.ScriptTi meout to the top of the code. It should
ideally be the topmost line. Again, 6000 seconds (100 mins) is way too long
before browser gives up. You might shorten it to say 600 seconds.

I still feel you need to query the database asynchronously, and poll it to see if the results have been returned.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"David Berry" <db****@mvps.or g> wrote in message
news:eL******** ******@TK2MSFTN GP10.phx.gbl...
Hi Manohar. I changed the code to:

Set cn = Server.CreateOb ject("ADODB.Con nection")
cn.Open "file name=e:\micro.u dl"
cn.ConnectionTi meout = 6000
Set cmd = Server.CreateOb ject("ADODB.Com mand")
cmd.ActiveConne ction = cn
cmd.CommandTime out = 6000

Server.ScriptTi meout = 6000

cmd.CommandText = "SELECT ........... "

Set rs = cmd.Execute(cmd .CommandText)

And now I'm getting an error that the operation isn't allowed while the object is open. The line it points to is

cn.ConnectionTi meout = 6000

Dave

"Manohar Kamath [MVP]" <mk*****@TAKETH ISOUTkamath.com > wrote in message news:Oj******** ******@tk2msftn gp13.phx.gbl...
> Dave,
>
> You can increase the CommandTimeout to a large number, but then you have to
> increase ASP script timeout as well. But then, if the time to execute the
> query is too long, your browser might just give up. Looks like the table is
> large, and as John suggested, the queried columns are not indexed.
>
> One thing you could do is to create a asyncronous query -- where the
results
> of the query go into a table, etc. Each query can be identified by a
number.
> You then implement a "Query executing, please wait..." page that checks
to
> see if the query has completed.
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "David Berry" <db****@mvps.or g> wrote in message
> news:ep******** ******@TK2MSFTN GP11.phx.gbl...
> > Hi John,
> >
> > Yes, I need them and no, they don't have indexes. I have no
control over
> > the database. It belongs to the customer and they don't want to

change
> it.
> >
> >
> > "John Blessing" <jb@**REMOVE**T HIS**LbeHelpdes k.com> wrote in

message > > news:yO******** **********@news fep4-glfd.server.ntl i.net...
> > > >>>>>>>>>>>>>>> >>>
> > > "David Berry" <db****@mvps.or g> wrote in message
> > > news:O0******** *****@tk2msftng p13.phx.gbl...
> > > Hi All. I have a SQL Statement on an ASP page that only returns 4 > > records.
> > > When I run it in SQL Server or Query Analyzer it runs in less than a
> > second.
> > > When I run it from my ASP page I get:
> > >
> > > Microsoft OLE DB Provider for SQL Server error '80040e31'
> > >
> > > Timeout expired
> > >
> > > the error line points to the rs.Open sql,con line.
> > >
> > > The SQL Statement is:
> > >
> > > SELECT DISTINCT CUST_SERVICE.AC CTNO As Acct, CONT_DATE,
SALES_REP_NAME,
> > > DESCRIP, PROD_TYPE, MODE FROM CUST_SERVICE CROSS JOIN CUSTOMER CROSS > JOIN
> > > ORDERS WHERE (CUST_SERVICE.A CCTNO NOT IN (SELECT DISTINCT acctno FROM
> > orders
> > > WHERE oredertype='Blo wout Print' or oredertype='Pri nt')) AND

CONT_DATE
> > > BETWEEN '12/23/03'AND'12/24/03' AND SALES_REP_NAME = 'Anne' AND
> PROD_TYPE
> > =
> > > 'P' AND CUSTOMER.BILLST = 'ct' AND ORDERS.orederty pe = 'Print' ORDER BY
> > > CUST_SERVICE.AC CTNO
> > >
> > > Any ideas what could be causing this? I upped the
Server.ScriptTi meout,
> > > Con.ConnectionT imeout and comCommand.Comm andTimeout and nothing

helps.
> > >
> > > Dave
> > > <<<<<<<<<<<<<<< <<<<<<<<<<<<<
> > >
> > > Do you really need the DISTINCTs? Are you likely to get more
than one
> > record
> > > with exactly the same info?
> > >
> > > Do the fields in your WHERE clause have indexes?
> > >
> > >
> > >
> > > --
> > > John Blessing
> > >
> > > http://www.LbeHelpdesk.com - Help Desk software priced to suit

all > > > businesses
> > > http://www.free-helpdesk.com - Completely free help desk

software ! > > > http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
> > >
> > >
> >
> >
>
>



Jul 19 '05 #11
Dave-

Other more capable minds have addressed the timeout issue so I will not
rehash it. However, you may want to consider reworking the query itself.
I suspect it's the subquery that's degrading your performance. Here's
what I believe would be a functionally equivalent query that may perform
better. Obviously, the only way to know for sure is to test it.

SELECT DISTINCT
CUST_SERVICE.AC CTNO As Acct,
CONT_DATE,
SALES_REP_NAME,
DESCRIP,
PROD_TYPE,
MODE
FROM
ORDERS,
CUSTOMER,
CUST_SERVICE LEFT JOIN
(
SELECT DISTINCT
acctno
FROM
orders
WHERE
oredertype='Blo wout Print' OR
oredertype='Pri nt'
) AS ORDERS_BPP ON
CUST_SERVICE.AC CTNO = ORDERS_BPP.acct no
WHERE
ORDERS_BPP.acct no IS NULL AND
CONT_DATE > '20031223' AND
CONT_DATE < '20031224' AND
SALES_REP_NAME = 'Anne' AND
PROD_TYPE = 'P' AND
CUSTOMER.BILLST = 'ct' AND
ORDERS.orederty pe = 'Print'
ORDER BY
CUST_SERVICE.AC CTNO

Notes:
1. Could you provide some details on the relationship between these
tables. The cross product joins seem out of place here. Guessing from
the names of the tables, I would suspect an ERD(Entity Relationship
Diagram) something like this:

ORDERS (+)---(1) CUSTOMER (1)---(+) CUST_SERVICE

If this is the case, your query could and should be taking advantage of
these relationships.

2. The difference between the above query and your original is the
placement of the Blowout Print/Print Orders subquery. In the original
query, the subquery is instantiated for each row of the main query. This
is unnecessary since the subquery is not dependant on the row data. This
is probably the reason for the poor performance.

3. You may want to consider using table aliases and using fully
qualified field references. It improves the legibility of the query and
eliminates ambiguity. For example, looking at the above query, I have no
idea to which table "DESCRIP" belongs.

4. You may want to consider using an ISO standard date format, i.e.
YYYYMMDD

5. You may want to consider replacing "BETWEEN" with less-than and
greater-than operators. Most modern databases engines have built-in
optimizations to do this conversion for you, but it is an unnecessary
extra step. The BETWEEN operator can also be somewhat confusing as it is
not clear whether it's inclusive or exclusive of the limits.

6. You may want to consider formatting your query text to improve their
legibility.

HTH
-Chris Hohmann
Jul 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7040
by: Mathieu Blais | last post by:
Hi, I need to capture the Script timeout error if that is possible. I know I can increase the timeout value in the server settings or in the scripts itself but I really want to make sure that no timeout situation will results as the standard script timeout error page. Can we do this ?? Help please.
3
6113
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection Timed out) I am using the Data Access Application Blocks as ASP.NET (using VB.NET) and SQL 2000. In there first question there can be up to 27 answers. So I figured instead of making 27 different trips to the database I woulc just concatenate my...
7
2157
by: Jack | last post by:
Hi, In my application, the main page is accessed via a login screen. A particular record is accessed based on the value of login page. Everything works fine. However, if this screen is kept idle (not sure for how long now), and then if I try to save, the following error message comes up: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) Syntax error (missing operator) in query expression 'SubgrantIntID ='....
3
55685
by: kant | last post by:
stringA= "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;PWD=password;Initial Catalog=DB;Data Source=127.0.0.1;Connect Timeout=30" stringB = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("DB.MDB") & ";Connect Timeout=30" Hi All,
1
521
by: Tommy | last post by:
hi, I have a database in sql 2000 and its size is 30 gb. problem faced by me is when From my front end application when my user updates a record for a category,900 records are suppose to be updated. Updation uses only 3 tables from my database,
1
4744
by: Steve | last post by:
I have a bit of "login authentication" code that in the event of a server error, connection error, etc will take a Looooooong time to timeout. I wanted to redesign it to call the DAL method in a separate thread (easy enough) w/ a callback for when it's done. The area I'm having trouble with is once I determine the timeout period has elapsed, how do I kill the thread safely? I asked a threading question here awhile ago and some kind...
1
4299
by: Mani | last post by:
Hi, This is the second time i am posting this question, since i didnt get any reponse from my previous post. When i tried to execute the script in browser, i am getting the following timeout error in the browser: -------------------------------------------------------------------------------------
3
14079
by: news | last post by:
Hi, I'm having a problem with the cURL library. It doesn't seem to obey the 'timeout' parameters. I set the CURLOPT_CONNECTTIMEOUT to, say, 1 second, and CURLOPT_TIMEOUT to whatever value. Then I'm fetching (via a GET request) some page from a _nonexistent_ domain - and I have to wait around 4 seconds for the timeout error to show up. (name lookup error)
7
2773
by: =?Utf-8?B?Sm9obiBTdGFnZ3M=?= | last post by:
Hello, Please read this all before giving an answer :) I'm doing some troubleshooting on a web application that my company wrote. It's written in asp.net 1.1. The error that the Event viewer gives is: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.