How to make a progress bar base on saving data in database ? Lets say I'm going to save 10 datas so i want to make a progress bar base on saving on that 10 datas ?
Printable View
How to make a progress bar base on saving data in database ? Lets say I'm going to save 10 datas so i want to make a progress bar base on saving on that 10 datas ?
This totaly depends on how the structure of your program is
But let's say you are working wisely and use stored procedures to update/insert data from a dataset.
As you know how many records you wil insert/update
set the max for progress bar to that number
You could rais an event after each record signaling that another record is saved and give the rownumber back in the event.
Next stop catch the event and put the rownumber into the progressbar value.
Why an event?
I'm assuming your interface and data Access code are separated.
Don't have any idea about this.Quote:
You could rais an event after each record signaling that another record is saved and give the rownumber back in the event.
to do this, you will need to understand two things. first, how to handle the database stuff, and two (more difficult) multi threading. ideally, you would want to have your program do its main function, ie updating the database, while signaling your progress bar to increment in one smooth, seamless, fasion. but, your main program, or the main thread, cant do both seamlessly. so, you multi thread. one thread will do the database stuff, send a command to the second thread to update the progress bar. viola! so, if you know you're going to have 100 updates, you would set your status bar to have a max of 100. with each database update, you would increment by 1. try googling "vb.net multithreading progress bar". this may not be easy at first but is well worth learning. good luck!
probably can use a backgroundworker and set you progress bar style property to scrolling marquee, this solves alot of problems when u dont know how much data u'll be receiving and also works well for saving...
I wouldn't worry about accurate progress for this. If it's worth displaying a progress bar at all, I would suggest just setting Style to Marquee so that the user sees that something is happening. By calculating and displaying accurate progress you will actually be slowing the whole thing down. Just populate a DataTable and save the lot in a single batch using a DataAdapter, which supports inline SQL or sprocs.