"J. Baute" <WU**********@spammotel.com> wrote in message
news:40*********************@news.skynet.be...
AFAIK there is no way to make an asynchronous call to a VBScript function,
since you can't define events in ASP, and that's something you need to be
able to know you results have return properly,
That's what I figured. Couldn't hurt to ask though.
but, since you managed to work async with a stored procedure through ADO,
maybe there's a way to call the COM object from an stored proc which is
perfectly possible if you are using MS SQL server as your DB.
Yech. No MS Sql Server here. I'm using Firebird. I could probably put
together a UDF to make the call, but that doesn't seem to be a proper
seperation of the data/application layers. More likely, I'll implement the
call to our middle tier in the com object, and let the middle tier create
the report.
Btw, I'm curious how that async stored-procedure magic works in ASP
though, would you mind sharing a snippet of code? :)
Sure.
We've got an include file called DbLibrary.asp, which contains all of the
logic for connecting/opening datasets/disconnecting. In this library is the
function for executing an async query:
function ExecuteSqlAsync(ASQL)
{
var vCount = 0;
vDBConnection.Execute(ASQL,vCount,0x10);
}
The 0x10 flag is equivalent to the constant adAsyncExecute.
The long running process is kicked off when a user makes a change to a
pricing model. We first generate a unique id for tracking the progress of
this event, then kick off the stored procedure via the above call. We then
redirect to a generic please wait page. This page shows a message to the
user, as well as an animated progress bar. It also contains an invisible
IFRAME, whose source is a page called WaitBackground.asp.
WaitBackground contains a refresh header set to 5 seconds. Each time the
page refreshes, it checks a table to see the status of the job (keyed by the
ID mentioned above, and updated by the stored procedure). If the job status
is complete, we use client side js to do a 'parent.document.location = ',
and show whatever page the user should be taken to.
All in all, it works very well, for both the short updates (the user sees
the progress screen for just a few seconds), and for longer updates (they
still have to wait, but are entertained by the animated progress bar moving
back and forth <g>).
Bob M..
<!--#include virtual='/Shared/Server/DbLibrary.asp' -->
<%
function SaveStopRateModel(AProcessStatusId)
{
vSql =
"execute procedure inv_save_stop_rate_revision(" +
Request('revid') + "," +
AProcessStatusId + ");"
ExecuteSqlAsync(vSql);
}
ConnectDb();
var vNewId = GetNewId2('PROCESS_STATUS_GEN');
SaveStopRateModel(vNewId);
Session("ProcessStatusUrl" + vNewId) = 'StopRateEdit.asp';
Session("ProcessStatusMsg" + vNewId) = escape(
'Your changes to the stop rate model are being saved.<BR><BR>' +
'Please wait while salescheck stop rates are updated based on your
selected "Effective Date".<BR><BR>' +
'This process could take up to two minutes. You will be returned to the
stop rate editor when complete.');
Response.redirect('PleaseWait.asp?processid=' + vNewId);
%>