Long Running process

B

Bob Murdoch

I'm developing an intranet application using W2k server and IE5.5 - 6.x
clients. I've got one particular function that calls a stored procedure to
update a number of records, depending on user input. The problem we have
run into is that this procedure can take a few minutes to complete in
certain circumstances, and of course IIS times out.

I've been doing some searching for a solution, but most of the answers I've
found relate to showing a 'Please wait' message while processing the page,
which doesn't help in this situation. The others I've found relate to using
MSMQ, which would probably help, but leads to a load of testing issues that
I'm not prepared to deal with at the moment.

Are there any other 'common' ways to handle this at the ASP level?

tia,

Bob M..
 
R

Ray at

Quote from aspfaq.com (#2194)


How do I prevent my ASP pages from waiting for backend activity?
4,334 requests - last updated Wednesday, August 14, 2002

If you are trying to run an executable or other backend process, see Adrian
Forbes' article:
Executing long-running tasks from ASP (invalid link of
http://www.aspfree.com/authors/adrian/aspexe.asp)

If you are trying to run long-running database tasks, then the following is
designed for a very specific scenario. Your
ASP page should:

1. initiate a long-running command that may cause a browser to time out;
and,
2. not need to show a user results from the command.
This means it should be a page which triggers an event in the database which
is NOT a recordset or other resultsobtaining
operation, and that the user isn't expecting direct feedback of any kind to
let them know that the process
has finished.
<%
set conn = server.createobject("ADODB.Connection")
conn.open "<connection string>"
conn.execute "<long-running command>",,&H00000010
response.write "The command is still running, but I'm not waiting!"
....
%>
You can test this technique by creating a single-column table:
CREATE TABLE dt (dt DATETIME)
And using a command like:

<%
set conn = server.createobject("ADODB.Connection")
conn.open "<connection string>"
sql = "INSERT dt VALUES(CURRENT_TIMESTAMP) WAITFOR DELAY '00:00:05' " &_
" INSERT dt VALUES(CURRENT_TIMESTAMP) WAITFOR DELAY '00:00:05' " &_
" INSERT dt VALUES(CURRENT_TIMESTAMP)"
response.write now()
conn.execute sql,,&H00000010
'...
%>
Now wait at least 10 seconds, go into the dt table manually, and check out
the differences in the dt column (and
compare to the now() value that you wrote to the browser).
One word of warning: errors get swallowed up by the provider when using
asynchronous methods, so you'll want to
employ this method carefully.
 
B

Bob Murdoch

Ray at said:
set conn = server.createobject("ADODB.Connection")
conn.open "<connection string>"
conn.execute "<long-running command>",,&H00000010
response.write "The command is still running, but I'm not waiting!"
...
%>

Great, I can get that to work in javascript. The question is, are we
leaking anything, or will we have problems with transactions not committing
with this?

We typically create the connection, start transaction, execute command,
commit, and then close the connection. Just wanna make sure we aren't
causing a leak here.

(btw, I did check Aspfaq.com, but the site seems to be down today),

thanks again,

Bob M..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top