I'm using ASP (VB Script) to generate some reports from a SQL Server
database. These queries often take a significant amount of time to complete,
and many of these reports consist of multiple queries.
One of the biggest problems end users have with this is that if the report
generation is cancelled (e.g. hitting the stop button on the browser) SQL
Server continues to process the request, which usually renders the server
unresponsive until the query completes.
I tried using Response.IsClie ntConnected to detect whether the client is
still connected to the server, and if not, I call cancel on the RecordSet
object. Unfortunately, this doesn't seem to work, and I'm trying to
understand why. Any advice as to why this doesn't do what I expect would be
greatly appreciated.
Here is the code I'm executing:
for i = 0 to 20
strSQL = objRpt.Subrepor tSQL(cstr(i)).S QLString
set rsts(i) = CreateObject("A DODB.Recordset" )
strSQL = objRpt.ParseSQL (strSQL,strpara mnames,strParam Values)
err.Clear
done = false
rsts(i).CursorT ype = 3 ' adOpenStatic
rsts(i).LockTyp e = 1 ' adLockReadOnly
rsts(i).CursorL ocation = 3 ' adUseClient
rsts(i).Open strSQL,whconn', ,adAsyncConnect
Do
if err <> 0 then
for each ce in whconn.Errors
Response.Write "Error - " & ce.NativeError & " - " &
ce.Description & "<br>"
next
Response.End
else
if not done then
Response.Write " <!-- Success -->" & vbcrlf
done = true
end if
end if
if not Response.IsClie ntConnected then
rsts(i).cancel
Response.Write "<!-- cancelled -->" & vbcrlf
exit Do
end if
AspSleep(2)
Loop
next
-----------------------
Thanks again for any advice,
-Gary 7 11384
If i'm not mistaken you can't "multitread " ASP through the coding
language. Meaning stop something you started until you finish it.
I would suggest setting up a stored procedure and doing something
database wise to increase your speed. Most of these problems can be
overcome with good database design.
hth,
Andrew
* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.
According to the documentation on the RecordSet object, cancel is supposed
to cancel the execution of a pending Open call. I also tried calling the
RecordSet open function with the adAsyncConnect option, but I get an error
when I use it.
We use stored procedures all over the place. The queries are very optimized.
There is just lots of data to process and lots of joins.
Thanks for your suggestions.
-Gary
"Andrew Durstewitz" <ad******@devbu ilder.org> wrote in message
news:3f******** *************@n ews.frii.net... If i'm not mistaken you can't "multitread " ASP through the coding language. Meaning stop something you started until you finish it.
I would suggest setting up a stored procedure and doing something database wise to increase your speed. Most of these problems can be overcome with good database design.
hth, Andrew
* * * Sent via DevBuilder http://www.devbuilder.org * * * Developer Resources for High End Developers.
You need to use adAsyncFetch or adAsyncFetchNon Blocking with recordsets, not
adAsyncConnect.
You should also tell ADO what the CommandType is. In this case it looks like
adCmdText, so the Open statement should look like this:
rsts(i).Open strSQL,whconn', , _
adAsyncFetchNon Blocking + adCmdText
Is the reason for the long execution time that you are returning a lot of
records? Have you looked into a paging solution?
Can you move some of this processing into a stored procedure so you're not
creating so much network traffic?
Perhaps you need to look into warehousing some of this data if you don't
need up-to-the-second information in these reports ...
HTH,
Bob Barrows
Gary wrote: Here is the code I'm executing:
for i = 0 to 20 strSQL = objRpt.Subrepor tSQL(cstr(i)).S QLString set rsts(i) = CreateObject("A DODB.Recordset" ) strSQL = objRpt.ParseSQL (strSQL,strpara mnames,strParam Values) err.Clear done = false rsts(i).CursorT ype = 3 ' adOpenStatic rsts(i).LockTyp e = 1 ' adLockReadOnly rsts(i).CursorL ocation = 3 ' adUseClient rsts(i).Open strSQL,whconn', ,adAsyncConnect
See an example at: http://www2.themanualpage.org/asp/as...connected.php3
I don't think you can cancel a SQL query by using methods of the
Recordset, because ASP doesn't support asynchronous event notifications.
But you can stop the execution of the script as described in the above
link. If you want to improve execution time on the ASP end, try reading
my article ASP Speed Tricks at http://www.somacon.com/aspdocs/ It
describes some methods to improve the speed of reports like the ones you
describe. If you're doing a read-only query and don't need recordset
navigation, then you probably want an adOpenForwardOn ly cursor, which
would also be a bit faster.
Shailesh
Gary wrote: According to the documentation on the RecordSet object, cancel is supposed to cancel the execution of a pending Open call. I also tried calling the RecordSet open function with the adAsyncConnect option, but I get an error when I use it.
We use stored procedures all over the place. The queries are very optimized. There is just lots of data to process and lots of joins.
Thanks for your suggestions.
-Gary
"Andrew Durstewitz" <ad******@devbu ilder.org> wrote in message news:3f******** *************@n ews.frii.net...
If i'm not mistaken you can't "multitread " ASP through the coding language. Meaning stop something you started until you finish it.
I would suggest setting up a stored procedure and doing something database wise to increase your speed. Most of these problems can be overcome with good database design.
hth, Andrew
* * * Sent via DevBuilder http://www.devbuilder.org * * * Developer Resources for High End Developers.
Gary wrote: It is all historical data, and is in fact a data warehouse (or perhaps more precisely, a data mart).
So why are multiple queries involved? I'm assuming there are due to your use
of what looks like an array of recordsets.
Could you utilize a stored procedure that ran all the queries and returned
multiple recordsets?
Bob
"Bob Barrows" <re*******@yaho o.com> wrote in message
news:OX******** ******@TK2MSFTN GP10.phx.gbl... So why are multiple queries involved? I'm assuming there are due to your
use of what looks like an array of recordsets. Could you utilize a stored procedure that ran all the queries and returned multiple recordsets?
The reports being generated contain subreports, each of which is a separate
query. And actually the product is designed to allow custom reports, so the
queries can be altered dynamically. If they were static, a stored procedure
would probably make sense. In other words I don't write any of the reports,
I just maintain the engine for generating them. Report writers could, I
suppose, write stored procedures that I could execute, but I wasn't planning
to go that way. I guess if I could prove that we would see significant gains
by writing future reports as stored procedures, it would be worth pursuing.
Even if they ran in 10 minutes, it's annoying to have to either shutdown SQL
Server or wait until it finishes before another report can be run. So the
goal, however it happens, is to get SQL to stop (the equivalent of hitting
the cancel button in Query Analyzer).
Thanks again.
-Gary
"Bob Barrows" <re*******@yaho o.com> wrote in message
news:uf******** ******@tk2msftn gp13.phx.gbl... You need to use adAsyncFetch or adAsyncFetchNon Blocking with recordsets,
not adAsyncConnect. You should also tell ADO what the CommandType is. In this case it looks
like adCmdText, so the Open statement should look like this: rsts(i).Open strSQL,whconn', , _ adAsyncFetchNon Blocking + adCmdText
I've tried adAsyncFetch, adAsyncFetchNon Blocking + adCmdText, and
adAsyncExecute, but none of them cause the call to recordset.open to behave
asynchronously.
I did see a MSKB article about an ADO bug where the open call may behave
synchronously even if adAsyncFetch is specified. In this case the example
code is VB, where the recordset is created using "WithEvents "
Private WithEvents rst As ADODB.Recordset
and I know the Event part of ADO is not supported by VBScript or JScript. So
I wonder if this is even possible from ASP.
-Gary This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul THompson |
last post by:
I have been working for some time to 1) detect tab and shift tab
events 2) control the focus on the basis of these events. I have
found that I can do this, but continue to have nagging problems.
One of the main problems at this point lies in cancelling the event.
I have found that the TAB fires the onkeypress in NN, but not in IE.
I can cancel the onkeypress fine in NN. The TAB fires the onkeydown
in IE and can be cancelled in IE. ...
|
by: InvisibleDuncan |
last post by:
I have a ListView that populates some fields whenever the user selects an item. However, if they change the data in the fields and then select a new item without saving, I want to display a message box that warns that their changes will be lost, and asks them to confirm whether to continue. Sounds simple
Unfortunately, the ListView's SelectedIndexChanged event cannot be cancelled, and it's actually called for each change in the selection. So,...
|
by: Sandra |
last post by:
Hi All,
I am running a VB.NET application which is using ADO to connect to an Oracle
9i database. I have a form which runs a query which can take a considerable
time to run depending on the criteria that is entered. This query is run on
a seperate thread as I wish to return control to the application while this
query runs. The user can cancel the execution of this query at any time by
hitting a cancel button.
My question is how to...
|
by: mgw |
last post by:
Hi,
I'm trying to cancel the Shift+F3 key combination in Netscape 7.2 from
performing the F3 key's default action of opening the Find dialog. I'm
unable thus far to prevent the Find dialog from appearing after
following steps listed in numerous posts in this group.
I detect the onkeydown event of the body as follows:
<body onkeydown="return bodyOnKeyPress(event);">
|
by: PromisedOyster |
last post by:
Hi
How do I cancel an event in a class where that event is setup in
another derived class. See example below.
Thanks
All our winforms are derived from one of our own classes, BaseForm.
This form does things like setup event handlers on each control so that
| |
by: Bob |
last post by:
I want to be able to cancel queries that take too long in a winforms app,
yet it's not clear to me how to do this cleanly. I want to do it in a way
that the server immediately stops execution, and not just free the client
up. Can anyone provide me with an example of the "right" way to do this?
TIA,
Bob
|
by: Ajab Gajab |
last post by:
Hi All,
I am developing an application in VB.Net where I need to provide user with
cancelling or stopping the current print job. Like, if a user clicks on
"stop" button, then printer should print already processed contents of a
page. This can be easily achieved in VB.Net by using e.HasMorePages = False.
However, if a user clicks on "Cancel" button, the printer should terminate
the current job immedialtely without printing processed...
|
by: Mark Anderson |
last post by:
Is it possible to identify the action of a user cancelling by the user
of file download dialog? (as opposed to something else being captured.
Ideally I'd like to do this for a IE6+/FF v1.5+/Safari v1.2+ base.
[I've a pass through ASP page capturing calls to a download component
that doesn't logs activity and which I can't edit. As my ASP page logs
the calls before download, a cancel by the user means the d/l count is 1
too high. As this...
|
by: pvsundarram |
last post by:
hey,
i am trying to cancel the keydown event for certain keycodes( for eg:-
enter key ).But the cancelling of this event is not happening in
firefox. Is there any way to cancel the event in the iframe.
CODE
=====
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US"
|
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,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
|
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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |