Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Fake progress bar whilst Stored Procedure runs using ASP

Question posted by: Dooza (Guest) on July 15th, 2008 01:55 PM
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 %>
Daniel Crichton's Avatar
Daniel Crichton
Guest
n/a Posts
July 15th, 2008
02:45 PM
#2

Re: Fake progress bar whilst Stored Procedure runs using ASP
Dooza wrote on Tue, 15 Jul 2008 14:52:42 +0100:
Quote:
I have a stored procedure that needs to be executed via an ASP page.

Quote:
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.

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

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

Quote:
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.

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

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

Quote:
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()

Quote:
%>
<% 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.

--
Dan



Dooza's Avatar
Dooza
Guest
n/a Posts
July 15th, 2008
02:55 PM
#3

Re: Fake progress bar whilst Stored Procedure runs using ASP
Daniel Crichton wrote:
Quote:
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

Dooza's Avatar
Dooza
Guest
n/a Posts
July 15th, 2008
03:55 PM
#4

Re: Fake progress bar whilst Stored Procedure runs using ASP
Dooza wrote:
Quote:
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 %>

Daniel Crichton's Avatar
Daniel Crichton
Guest
n/a Posts
July 16th, 2008
04:05 PM
#5

Re: Fake progress bar whilst Stored Procedure runs using ASP
Dooza wrote on Tue, 15 Jul 2008 16:52:44 +0100:
Quote:
Dooza wrote:
Quote:
>Response object error 'ASP 0156 : 80004005'

Quote:
Quote:
>Header Error

Quote:
Quote:
>/webshop/upload.asp, line 26

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

Quote:
Quote:
>Any idea how I can get pass this hurdle?

Quote:
I ended up using some javascript instead:

Quote:
<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.

--
Dan



 
Not the answer you were looking for? Post your question . . .
189,071 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors