Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Fake progress bar whilst Stored Procedure runs using ASP

Reply
Thread Tools

Fake progress bar whilst Stored Procedure runs using ASP

 
 
Dooza
Guest
Posts: n/a
 
      07-15-2008
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 %>
 
Reply With Quote
 
 
 
 
Daniel Crichton
Guest
Posts: n/a
 
      07-15-2008
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.

--
Dan


 
Reply With Quote
 
 
 
 
Dooza
Guest
Posts: n/a
 
      07-15-2008
Daniel Crichton wrote:
> 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
 
Reply With Quote
 
Dooza
Guest
Posts: n/a
 
      07-15-2008
Dooza wrote:
> 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 %>
 
Reply With Quote
 
Daniel Crichton
Guest
Posts: n/a
 
      07-16-2008
Dooza wrote on Tue, 15 Jul 2008 16:52:44 +0100:

> Dooza wrote:
>> 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>


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

--
Dan


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
disable title bar, status bar, and address bar of a browser window Matt ASP .Net 0 08-21-2004 03:50 AM
Progress bar to show the progress of a task Charlie Zhang Java 3 08-16-2004 05:53 PM
progress bar or guage bar Rob ASP General 6 07-12-2003 09:46 AM



Advertisments