Progress Bar 
Author Message
 Progress Bar


Quote:
> Just a simple one... How can I make a Prgress Bar that count on how many
> percent I'm in the database process..??? Like "insert into Table2 select *
> from Table1"

You can't. That's a single operation and won't return until finished, so you
will be unable to execute code to update the progress bar. Not only that,
but SQL Server has no way of telling you how far it is in the update
anyways.


Sun, 03 Feb 2002 03:00:00 GMT  
 Progress Bar
Ic... but is it possible if i just want to createe a Form that only show the
current processing Record No. (Or field value like PK value)? I guess it's
possible right? But how can I get the the current field value from SQL sp
and pass the parameter back to VB and how VB can get the returned parameter?

Edwin

Quote:
> You can't. That's a single operation and won't return until finished, so
you
> will be unable to execute code to update the progress bar. Not only that,
> but SQL Server has no way of telling you how far it is in the update
> anyways.



Mon, 04 Feb 2002 03:00:00 GMT  
 Progress Bar
Edwin,

Nope...
SQL Server processes your statement synchronously. The only option would be
a cursor and loop the rows (and if you did that, you would _really_ need the
info, cause it would most probably be dead slow :-).

--
Tibor Karaszi
MCDBA, MCSE, MCSD, MCT, SQL Server MVP
Cornerstone Sweden AB
Please reply to the newsgroup only, not by email.


Quote:
> Ic... but is it possible if i just want to createe a Form that only show
the
> current processing Record No. (Or field value like PK value)? I guess it's
> possible right? But how can I get the the current field value from SQL sp
> and pass the parameter back to VB and how VB can get the returned
parameter?

> Edwin

> > You can't. That's a single operation and won't return until finished, so
> you
> > will be unable to execute code to update the progress bar. Not only
that,
> > but SQL Server has no way of telling you how far it is in the update
> > anyways.



Mon, 04 Feb 2002 03:00:00 GMT  
 Progress Bar


Quote:
> Ic... but is it possible if i just want to createe a Form that only show
the
> current processing Record No. (Or field value like PK value)? I guess it's
> possible right? But how can I get the the current field value from SQL sp
> and pass the parameter back to VB and how VB can get the returned

parameter?

I'll say it again: YOU CAN'T. Don't be fooled by the "progress bar" you may
have seen in MS Access. Access doesn't really know how far along the query
is; it's just smoke and mirrors.

If you are updating your records via a single SQL UPDATE statement then SQL
Server will report NO PROGRESS WHATSOEVER. Your only hope would be to update
each record manually via a recordset, and that would be way slower than an
UPDATE statement. I realize users can get impatient, but it's better that
the update take 4 minutes with no sign of progress than 30 minutes with
feedback. 'Course that's just my opinion....



Mon, 04 Feb 2002 03:00:00 GMT  
 Progress Bar
Well you can make a "Smoke and mirrors" Progress Bar yourself, but remember,
that just as Jeff said, it will be just smoke and mirrors..... Here is the
way to do it, should you decide to:

1.  Do a bunch of testing on your server to generate a simple data table
that can be used to roughly predict how long an Insert will tkae for this
query, as a function of the number of records it will update.  It may be
linear,

Num Records      Time
        10                    1 sec
        20                    2 Sec
        100                10 sec
       1000                100 sec
    etc.

or it may expose a non-linear but obvious pattern.  In any event, with
enough data points you will be able to use a statistical analysis tool (I've
forgotten the fancy words for this but it's something like "regression
Analysis" _ There's tons of info on the various methods and how to do them
in teh Excel help files,  and Excel can do it for you)  Anyway when you're
done you'll have a relatively simple predictor formula that should get
reasonably close to the right answer, based on the number of records that
the Update will affect.

2.  Then in your client code, before you run the actual Update Query, run a
Select Count(*) From TableName Query With a Where Clause Condition that
matches exactly the Where Clause of the Update..... That should tell you how
many records the Update will affect......

3.  Then, uding the formula you came up with in Step 1, and the count
generated in Step 2, calculate (Predict) how long the Update will run, and
construct and populate your progress bar based on the predicted completion
time and a timer.....

4.  If you want to get fancy and deceptive, vary the rate at which it fills
up, in a quasi-random manner, and never let it go the last ten percent until
the query returns with a successfully completed message, and then wait an
extra few seconds as you fill the last ten percent up..... <grin>


Quote:



> > Ic... but is it possible if i just want to createe a Form that only show
> the
> > current processing Record No. (Or field value like PK value)? I guess
it's
> > possible right? But how can I get the the current field value from SQL
sp
> > and pass the parameter back to VB and how VB can get the returned
> parameter?

> I'll say it again: YOU CAN'T. Don't be fooled by the "progress bar" you
may
> have seen in MS Access. Access doesn't really know how far along the query
> is; it's just smoke and mirrors.

> If you are updating your records via a single SQL UPDATE statement then
SQL
> Server will report NO PROGRESS WHATSOEVER. Your only hope would be to
update
> each record manually via a recordset, and that would be way slower than an
> UPDATE statement. I realize users can get impatient, but it's better that
> the update take 4 minutes with no sign of progress than 30 minutes with
> feedback. 'Course that's just my opinion....



Mon, 04 Feb 2002 03:00:00 GMT  
 Progress Bar

Quote:



>> Ic... but is it possible if i just want to createe a Form that only show
>the
>> current processing Record No. (Or field value like PK value)? I guess
it's
>> possible right? But how can I get the the current field value from SQL sp
>> and pass the parameter back to VB and how VB can get the returned
>parameter?

>I'll say it again: YOU CAN'T. Don't be fooled by the "progress bar" you may
>have seen in MS Access. Access doesn't really know how far along the query
>is; it's just smoke and mirrors.

>If you are updating your records via a single SQL UPDATE statement then SQL
>Server will report NO PROGRESS WHATSOEVER. Your only hope would be to
update
>each record manually via a recordset, and that would be way slower than an
>UPDATE statement. I realize users can get impatient, but it's better that
>the update take 4 minutes with no sign of progress than 30 minutes with
>feedback. 'Course that's just my opinion....

I don't think it's nice if user gets no respond from app for 4 minutes. So I
would consider making some "sign of life"  (maybe some flashing lights)
managed by separate thread (via Timer, off course).

Mario Orsolic



Tue, 05 Feb 2002 03:00:00 GMT  
 Progress Bar
Quote:
> I don't think it's nice if user gets no respond from app for 4 minutes. So
I
> would consider making some "sign of life"  (maybe some flashing lights)
> managed by separate thread (via Timer, off course).

Would u mind to give me some idea?

Is it like i make a timer with 1 second interval and make the lights flash
until it finish?(but where can i get the lights? a bitmap or what?) Thanks

Edwin



Tue, 05 Feb 2002 03:00:00 GMT  
 Progress Bar

Quote:
> > I don't think it's nice if user gets no respond from app for 4 minutes.
So
> I
> > would consider making some "sign of life"  (maybe some flashing lights)
> > managed by separate thread (via Timer, off course).
> Would u mind to give me some idea?

> Is it like i make a timer with 1 second interval and make the lights flash
> until it finish?(but where can i get the lights? a bitmap or what?) Thanks

Check out the Animation control, Edwin.  It's simple and effective for cases
where you don't know how long something is going to take and you don't need
to muck about with timers or APIs.

Bertie



Tue, 05 Feb 2002 03:00:00 GMT  
 Progress Bar


Quote:
> I don't think it's nice if user gets no respond from app for 4 minutes. So
I
> would consider making some "sign of life"  (maybe some flashing lights)
> managed by separate thread (via Timer, off course).

I still say it won't work. VB will not process ANY events while the update
is happening, including Timer events. The proper thing to do would be to
execute the update asynchronously with ADO. Then you can process events.


Tue, 05 Feb 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. File Loading Progress Form with Progress Bar

2. How do I display a progress bar showing progress for database replication

3. How do I display a progress bar showing progress for database replication

4. Progress bar measuring FileCopy progress

5. Status Bar/Progress Bar

6. Progress bar in status bar for .NET

7. Progress Bar in Status Bar

8. Progress bar on a status bar

9. Progress bar in a status bar

10. Progress bar in a Status bar panel?

11. Progress bar in a status bar

12. Resizing a Progress Bar in the Status Bar

 

 
Powered by phpBB® Forum Software