Updating a progress bar in .net app, while executing a stored procedure

I have a small application written in vb.net. It has a function that calls a stored procedure(SQL Server) using sql command object. Now the functionality of the stored procedure is to perform a mass update of a table on various rows. Lets say almost 5000 rows based on certain condition for each of the row. For this I use a cursor.  

How can I put a progress bar in my .net application and update the user when each of the rows gets updated by the stored procedure? Currently I dont get a response from the sp until its over. Any idea?

Who is Participating?
Barry CunneyCommented:
Yes if you have time threading would definitely be worth exploring
Barry CunneyCommented:
If you wanted to get more complex but have more control and possibly a more professional approach would be to use threads.

You would instantiate a secondary worker thread that would handle and monitor the stored procedure as it works. You would then code this worker thread to send messages back to the interface thread which would update the progress bar on the interface - This approach should leave the interface 100% responsive
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

DoubtManAuthor Commented:
Hi Bcunney,
reading your solution seems to be promising. However, will it be possible for you to give an example how to do that? I mean with some code?

Thanks very much.
Threading is a better solution, i agree, but, as bcunney said, a little more complex.  It all depends on how in depth you want to get.
Barry CunneyCommented:
I actually had done exactly what you are trying to do 10 years ago in C++ -
I had a worker thread that executed a SQL Server 2000 stored procedure(the stored proc ran a SQL Profiler trace)
This worker thread was coded to send windows messages back to the main thread and as the main thread received these messages it updated the interface accordingly(by displaying messages to the user in the status bar panel on the form - like 'Trace running', 'Trace completed' etc )
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.