Results 1 to 6 of 6

Thread: Wait while saving data Question

  1. #1

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    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 ?

  2. #2
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    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.

  3. #3

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    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.

  4. #4
    Hyperactive Member jasonwucinski's Avatar
    Join Date
    Mar 2010
    Location
    Pittsburgh
    Posts
    452

    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!

  5. #5
    Addicted Member vb_ftw's Avatar
    Join Date
    Dec 2010
    Posts
    139

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

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width