Stored Proc Progress bar

I have a stored proc that synchronises two db's. My question is when i call the stored proc from my application it shoukd show the status back to the user. something like a progress bar. when i googled i came through something called Background worker. can anyone one give an example how i can use it. or is there any other way.
AnnaJames77Asked:
Who is Participating?
 
CodeCruiserCommented:
The backgroundworker has 3 methods/events. You put the code that is executing the stored procedure in the backgroundworker.DoWork method. You may use the backgroundwork.ReportProgress to update the UI about the progress of the process but you wont need that in this case. Then you have the backgroundworker.WorkerCompleted which can be used to clean up stuff such as hiding the progressbar and showing a message that processing has completed.



1) Add a backgroundworker to the form. Also add a progressbar and set its style to marquee.
2) Create an eventhandler in code for DoWork method
3) Paste code in that method and call the backgroundworker.RunWorkerAsync when you want to start the processing (such as in a button click). Before that, set the progressbar to visible
4) When the backgroundworker completes, hide the progressbar.









0
 
DhaestCommented:
The biggest problem with your progress bar will be setting the initial value of the "100%".
How do you know how long your sp will run ?
What you perhaps can do is split the sp into several smallers (fe 5 pieces) and update the progressbar each time when you call the next one.

How To Update Controls Using BackgroundWorker in VB.NET
http://vbnotebookfor.net/2007/09/24/how-to-update-controls-using-backgroundworker-in-vbnet/
0
 
CodeCruiserCommented:
>synchronises two db's.
How?

I think you would want to use a marquee style progressbar so that the stored procedure keeps running in the background but the UI is responsive so user is not frustrated.

http://www.youtube.com/watch?v=ZiVv_uPWOEs
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
AnnaJames77Author Commented:
thankyou CodeCruiser. but how can we know that the stored proc has completed its excution???
0
 
dexion432Commented:
"but how can we know that the stored proc has completed its excution"

returns a return value or writes an "i am completed" row into the db and you poll it
0
 
DhaestCommented:
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
CodeCruiserCommented:
If you dont use asynchronous ADO.NET, how do you know currently that stored procedure has completed? All you do is that you move the current code in backgroundworker and add a progressbar on the form.
0
 
AnnaJames77Author Commented:
Codecrusier can you pls let me know how to use the backgroundworker. When i googled too i got such an answer. but i donot know how to use it. In google got many answers but dint get one which uses a stored procedure with backgroundworker. CAn you help on this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.