none
Strongly-typed dataset not updating record RRS feed

  • Question

  • I have a strongly-typed dataset that I created using the TableAdapter (in VS 2005).  When I modify a record, it's not being updated.

     

    Here's the steps that I'm doing:

     

    row = states.FindByAbbr(sAbbr)
    row.bird = textBird.Text
    row.flower = textFlower.Text
    row.AcceptChanges()
    states.AcceptChanges()
    statesDA.Update(states)

     

    I doubled checked properties of the table adapter and there is a SQL statement for the UpdateCommand.

     

    Anyone have any suggestions?

     

    Richard

     

    Saturday, December 6, 2008 12:19 AM

All replies

  • The Update methods looks for changes in the 'Added', 'Modified' or 'Deleted' RowState.

    By calling AcceptChanges, you accepted the modified row and made it an unchanged row - therefore Update had no changes to operate on.

     

    Try with just the following.

    Code Snippet

    row = states.FindByAbbr(sAbbr)
    row.bird = textBird.Text
    row.flower = textFlower.Text
    statesDA.Update(states)

     

     

    Monday, December 8, 2008 9:35 PM
    Moderator
  • Thanks.  That was the solution.

    Richard
    Saturday, December 20, 2008 2:43 AM