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

Hello,
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.  

Query:
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?

Thanks.
DoubtManAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Barry CunneyConnect With a Mentor Commented:
Yes if you have time threading would definitely be worth exploring
http://www.vbforums.com/showthread.php?t=651352
0
 
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
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
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.
0
 
binaryevoCommented:
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.
0
 
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 )
0
 
binaryevoCommented:
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.