problems with datagridview saving currently highlighted row

dotolee

Member
Joined
Nov 30, 2004
Messages
20
Programming Experience
10+
hi there. i have a windows forms app which displays a bunch of records from my sql database. when i modify records in the grid and click on save, all changes are saved EXCEPT the changes made to the currently highlighted row - they aren't written out the database until i exit the actual program. i know this because when i click on my refresh button, the grid is refreshed and the data in the last row i changed is the old data. can you give me some ideas on how to troubleshoot this?

My code for the save button look like:

Private Sub TerritoryBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TerritoryBindingNavigatorSaveItem.Click

Me.TerritoryBindingSource.EndEdit()
Me.HHolderBindingSource.EndEdit()

' save the row references for all the records that have been added or changed in both ds
Dim TerritoryUpdates() As DataRow = TerritoryDS.Territory.Select("", "", DataViewRowState.Added Or DataViewRowState.ModifiedCurrent Or DataViewRowState.Deleted)
Dim HHUpdates() As DataRow = TerritoryDS.HHolder.Select("", "", DataViewRowState.Added Or DataViewRowState.ModifiedCurrent Or DataViewRowState.Deleted)
Try
Me.TerritoryTableAdapter.Update(TerritoryUpdates)
Me.HHolderTableAdapter.Update(HHUpdates)
MsgBox("Changes Saved")
Catch ex As Exception
MsgBox("Unable to save changes")
End Try
End Sub


The refresh button looks lke:

Me.HHolderTableAdapter.ClearBeforeFill = False
Me.TerritoryTableAdapter.ClearBeforeFill = False
Me.TerritoryTableAdapter.FillBySortedName(TerritoryDS.Territory)
Me.HHolderTableAdapter.Fill(TerritoryDS.HHolder)
 
Back
Top