VS 2015 Updating a Data Set-VBForums
Results 1 to 4 of 4

Thread: Updating a Data Set

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2017
    Posts
    17

    Updating a Data Set

    Hello everyone, I'm having issues with a form that shows, within a DataGridView, all the orders within a Table, when I click on any line a new Form shows up and I edit the order. When I finish making the changes, even though I tried to update the DataGridView control, the order's total remains unchanged, so when I close the form and load it up again, that's when I see the new total. I debugged and found out the DataSet where the DataGridView is getting data from, is not updating so that's why I see the old total. How can I force the DataSet to update and get the whole Orders table again?

    Thanks

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,369

    Re: Updating a Data Set

    If you're using a BindingSource you can call it's ResetBindings method to update any controls the BindingSource is bound to.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,602

    Re: Updating a Data Set

    If it's not working then you did it wrong. If we can't see what you did then we can't see what you did wrong.

    That said, there's no "forcing" the DataSet to update. You presumably get the existing data from fields of the DataRow or DataRowView bound to the row they clicked in order to pass it to the new form. You simply set those same fields with the new data and the grid will reflect that change. If you pass the DataRow or DataRowView to the dialogue then it can do the updating, or you can pass in the individual values and then get the individual values back out again and update the row in the main form. For an example of the former, follow the CodeBank link in my signature below and check out my thread on Updating A Grid Row.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,602

    Re: Updating a Data Set

    My guess is that, like a lot of people, you're doing things backwards. In this situation, a lot of people have the dialogue save the changes to the database and then wonder why the grid in the main form doesn't change. That's because they are not changing it. What you should be doing, as described above, is making the changes to your DataTable, and thus your grid, first. You then save the changes from the DataTable back to the database and that is done in the main form. The dialogue doesn't know anything about the database. All data access happens in the main form, not spread out over multiple forms.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.