Can I change the background of the blog?
Fake progress bar whilst Stored Procedure runs using ASP
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > ASP web-programming > Fake progress bar whilst Stored Procedure runs using ASP 16 July 2008 19:53:36

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Fake progress bar whilst Stored Procedure runs using ASP

Dooza 16 July 2008 19:53:36
 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.ActiveConn­ection = MM_aclv4_STRING
cmUpload.CommandTex­t = "dbo.updateWebshop"­
cmUpload.Parameters­.Append cmUpload.CreatePara­meter("@RETURN_VALUE­", 3, 4,2)
cmUpload.CommandTyp­e = 4
cmUpload.CommandTim­eout = 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 %>
Add comment
Daniel Crichton 15 July 2008 18:35:34 permanent link ]
 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.ActiveConn­ection = MM_aclv4_STRING cmUpload.CommandTex­t =
"dbo.updateWebshop"­
cmUpload.Parameters­.Append cmUpload.CreatePara­meter("@RETURN_VALUE­", 3,
4,2)
cmUpload.CommandTyp­e = 4 cmUpload.CommandTim­eout = 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


Add comment
Dooza 15 July 2008 18:47:10 permanent link ]
 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
Add comment
Dooza 15 July 2008 19:52:44 permanent link ]
 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.ActiveConn­ection = MM_aclv4_STRING
cmUpload.CommandTex­t = "dbo.updateWebshop"­
cmUpload.Parameters­.Append cmUpload.CreatePara­meter("@RETURN_VALUE­", 3, 4,2)
cmUpload.CommandTyp­e = 4
cmUpload.CommandTim­eout = 0
cmUpload.Prepared = true
cmUpload.Execute()

%>
<% If cmUpload.Parameters­("@RETURN_VALUE") = 0 Then
Response.Write("<sc­ript language=javascript­>window.location =
""results.asp"";</s­cript>")
%>
<% Else %>
<p>Error Code: <%= cmUpload.Parameters­("@RETURN_VALUE") %></p>
<% End if %>
Add comment
Daniel Crichton 16 July 2008 19:53:36 permanent link ]
 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


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > ASP web-programming > Fake progress bar whilst Stored Procedure runs using ASP 16 July 2008 19:53:36

see also:
passing an object using session var
Re: svn commit: r480525…
"Compacting" a relation
пройди тесты:
see also:
Problem when new cartridge(s) are…

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .