Results 1 to 2 of 2

Thread: DataRowState.Modified

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    180

    DataRowState.Modified

    Hi,

    I have a datagridview bound to a datatable, I want to check which rows have been updated and then update my database.

    I have this

    Dim dt As DataTable = dgMarketingWebsites.DataSource

    For Each r As DataRow In dt.Rows
    If r.RowState = DataRowState.Modified Then
    ' Do update here
    End If
    Next

    The problem is that the state always seems to be added, even if changes have been made, am I missing something?


    Thanks

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

    Re: DataRowState.Modified

    You don't save changes that way anyway. Check this out.

    If the rows are Added then either you are adding them yourself or you have set the AcceptChangesDuringFill property of your DataAdapter to False, in which case the rows are not being set to Unchanged after they're retrieved.
    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