DoubtMan
asked on
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.
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.
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
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
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 )
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 )
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/d673e605-84cc-4b96-93f4-2861aefb107b/