|
-
Dec 29th, 2010, 04:14 AM
#1
Thread Starter
Fanatic Member
Wait while saving data Question
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 ?
-
Dec 29th, 2010, 04:35 AM
#2
Re: Wait while saving data Question
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.
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Dec 30th, 2010, 12:39 AM
#3
Thread Starter
Fanatic Member
Re: Wait while saving data Question
You could rais an event after each record signaling that another record is saved and give the rownumber back in the event.
Don't have any idea about this.
-
Dec 30th, 2010, 01:42 AM
#4
Hyperactive Member
Re: Wait while saving data Question
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!
if i was able to help, rate my post!
-
Dec 30th, 2010, 03:15 AM
#5
Addicted Member
Re: Wait while saving data Question
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...
-
Dec 30th, 2010, 01:25 PM
#6
Re: Wait while saving data Question
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|