Solved

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

Posted on 2012-04-12
7
798 Views
Last Modified: 2012-04-12
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.
0
Comment
Question by:DoubtMan
  • 3
  • 3
7 Comments
 
LVL 14

Expert Comment

by:binaryevo
ID: 37837951
0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 37837977
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
 

Author Comment

by:DoubtMan
ID: 37838027
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 14

Expert Comment

by:binaryevo
ID: 37838089
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
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 500 total points
ID: 37838402
Yes if you have time threading would definitely be worth exploring
http://www.vbforums.com/showthread.php?t=651352
0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 37838419
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
 
LVL 14

Expert Comment

by:binaryevo
ID: 37838689
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question