I have a winforms app with sql for the database.
When the records that are displayed in my Itemsdatagridview (child table) are modified I need to update quantities in another table so I need to be able to capture only the modified records and then loop through them to make changes in the other table when saving these changes.
Currently on save I am looping through the datagridview records and updating the quantities in the other table but am not checking if the state of that record is modified, which is the source of my problem. I am wondering of a way to get the modified records of the Itemsdatagridview records so I can loop through them.
I have been looking at the rowstate, which would work great, but the examples create a temp dataset which does not seem to be working for me.
I think I have been overthinking this and was hoping a fresh set of eyes or someone with more experience would be able to help. I don't need to update my Items table from the modified records, I would just need to use that to update my quantities in my other table. I think :confused:
-Stacy
This was the example I was trying to use.
I get an error on the last like adapter.Update(tempDataSet)
When the records that are displayed in my Itemsdatagridview (child table) are modified I need to update quantities in another table so I need to be able to capture only the modified records and then loop through them to make changes in the other table when saving these changes.
Currently on save I am looping through the datagridview records and updating the quantities in the other table but am not checking if the state of that record is modified, which is the source of my problem. I am wondering of a way to get the modified records of the Itemsdatagridview records so I can loop through them.
I have been looking at the rowstate, which would work great, but the examples create a temp dataset which does not seem to be working for me.
I think I have been overthinking this and was hoping a fresh set of eyes or someone with more experience would be able to help. I don't need to update my Items table from the modified records, I would just need to use that to update my quantities in my other table. I think :confused:
-Stacy
This was the example I was trying to use.
Code:
Private Sub UpdateDataSet(ByVal dataSet As DataSet)
' Check for changes with the HasChanges method first.
If Not dataSet.HasChanges(DataRowState.Modified) Then
Exit Sub
End If
' Create temporary DataSet variable and
' GetChanges for modified rows only.
Dim tempDataSet As DataSet = _
dataSet.GetChanges(DataRowState.Modified)
' Check the DataSet for errors.
If tempDataSet.HasErrors Then
' Insert code to resolve errors.
End If
' After fixing errors, update the data source with
' the DataAdapter used to create the DataSet.
adapter.Update(tempDataSet)
End Sub