Fake progress bar whilst Stored Procedure runs using ASP

D

Dooza

I have a stored procedure that needs to be executed via an ASP page.

The SP does a number of tasks, mainly comparing a local table against a
linked server table, and updating/inserting/deleting where necessary. It
does this on 4 tables, one of them being fairly large, which will keep
on growing.

I have constructed the ASP page, made an animated GIF for the fake
progress bar, and then inserted the command to run the SP.

I then check the return value and if its 0 the page is redirected to a
results page which shows a table.

When I run this page I don't get to see the animated gif, the page
pauses until the SP is complete and redirects direct to the results page.

How can I make the page load the animated gif first, and then once the
SP has run and is successful redirect?

<img src="progress.gif" width="150" height="150" />
<p>Please wait, upload in progress...</p>
<%

set cmUpload = Server.CreateObject("ADODB.Command")
cmUpload.ActiveConnection = MM_aclv4_STRING
cmUpload.CommandText = "dbo.updateWebshop"
cmUpload.Parameters.Append cmUpload.CreateParameter("@RETURN_VALUE", 3, 4,2)
cmUpload.CommandType = 4
cmUpload.CommandTimeout = 0
cmUpload.Prepared = true
cmUpload.Execute()

%>
<% If cmUpload.Parameters("@RETURN_VALUE") = 0 Then
Response.Redirect("results.asp")
Else%>
<p>Error Code: <%= cmUpload.Parameters("@RETURN_VALUE") %></p><% End if %>
 
D

Daniel Crichton

Dooza wrote on Tue, 15 Jul 2008 14:52:42 +0100:
I have a stored procedure that needs to be executed via an ASP page.
The SP does a number of tasks, mainly comparing a local table against a
linked server table, and updating/inserting/deleting where necessary.
It does this on 4 tables, one of them being fairly large, which will
keep on growing.
I have constructed the ASP page, made an animated GIF for the fake
progress bar, and then inserted the command to run the SP.
I then check the return value and if its 0 the page is redirected to a
results page which shows a table.
When I run this page I don't get to see the animated gif, the page pauses
until the SP is complete and redirects direct to the results
page.
How can I make the page load the animated gif first, and then once the SP
has run and is successful redirect?
<img src="progress.gif" width="150" height="150" />
<p>Please wait, upload in progress...</p>
<%
set cmUpload = Server.CreateObject("ADODB.Command")
cmUpload.ActiveConnection = MM_aclv4_STRING cmUpload.CommandText =
"dbo.updateWebshop"
cmUpload.Parameters.Append cmUpload.CreateParameter("@RETURN_VALUE", 3,
4,2)
cmUpload.CommandType = 4 cmUpload.CommandTimeout = 0 cmUpload.Prepared
= true cmUpload.Execute()
%>
<% If cmUpload.Parameters("@RETURN_VALUE") = 0 Then
Response.Redirect("results.asp")
Else%>
<p>Error Code: <%= cmUpload.Parameters("@RETURN_VALUE") %></p><% End if
%>



Have you got Buffering turned on? If so, put a Response.Flush after the img
tag, but before the command Execute call. So long as you're not inside a
table then the browser should render what has been sent up to that point.
 
D

Dooza

Daniel said:
Have you got Buffering turned on? If so, put a Response.Flush after the img
tag, but before the command Execute call. So long as you're not inside a
table then the browser should render what has been sent up to that point.

Hi Daniel.
Buffering is on by default in IIS6, so I tried what you said, and it
almost worked... the Response.Redirect at the end of the update has
caused this error:

Response object error 'ASP 0156 : 80004005'

Header Error

/webshop/upload.asp, line 26

The HTTP headers are already written to the client browser. Any HTTP
header modifications must be made before writing page content.

Any idea how I can get pass this hurdle?

Cheers,

Steve
 
D

Dooza

Dooza said:
Response object error 'ASP 0156 : 80004005'

Header Error

/webshop/upload.asp, line 26

The HTTP headers are already written to the client browser. Any HTTP
header modifications must be made before writing page content.

Any idea how I can get pass this hurdle?

I ended up using some javascript instead:

<img src="progress.gif" width="150" height="150" />
<p>Please wait, update in progress...</p>
<% Response.Flush() %>
<%

set cmUpload = Server.CreateObject("ADODB.Command")
cmUpload.ActiveConnection = MM_aclv4_STRING
cmUpload.CommandText = "dbo.updateWebshop"
cmUpload.Parameters.Append cmUpload.CreateParameter("@RETURN_VALUE", 3, 4,2)
cmUpload.CommandType = 4
cmUpload.CommandTimeout = 0
cmUpload.Prepared = true
cmUpload.Execute()

%>
<% If cmUpload.Parameters("@RETURN_VALUE") = 0 Then
Response.Write("<script language=javascript>window.location =
""results.asp"";</script>")
%>
<% Else %>
<p>Error Code: <%= cmUpload.Parameters("@RETURN_VALUE") %></p>
<% End if %>
 
D

Daniel Crichton

Dooza wrote on Tue, 15 Jul 2008 16:52:44 +0100:
I ended up using some javascript instead:
<img src="progress.gif" width="150" height="150" /> <p>Please wait,
update in progress...</p>

Ah, I missed the Response.Redirect further down in your code. Using client
scripting is pretty much the only workaround for this.
 

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,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top