Datagridview update not working
I am trying to update my DGV with the following code. i have generated SQL update command in the tableadapter. but still the changes are not affecting the DB.
Any suggestions?
Code:
If Me.TabControl1.SelectedTab.Equals(Locn) Then
If MWLocations.HasChanges Then
Try
Me.LocationsBindingSource.EndEdit()
Me.MWLocations.AcceptChanges()
Me.LocationsTableAdapter.Update(Me.MWLocations.Locations)
MsgBox(" Update successful ")
Catch ex As Exception
MsgBox(" Update failed ")
End Try
End If
End If
Re: Datagridview update not working
There are hardly any reasons to ever have to call AcceptChanges. By stating that, you are resetting the row states of your dataset/datatable and telling it that none of the rows have changed.
Re: Datagridview update not working
alright, even after removing it the changes are not affecting the DB :(
Re: Datagridview update not working
Re: Datagridview update not working
I wish I had a $ for every time I've posted this. It's several times a week on average.
The first thing to do is to test the return value of your Update method. If it's zero then there are no changes in your DataTable to save, at least with the SQL you're executing. If it's not zero then data is being saved and you're simply looking for it in the wrong place or at the wrong time, which is not as silly as it sounds.
Re: Datagridview update not working
how do i test the return value of my Update method?
Re: Datagridview update not working
Quote:
Originally Posted by
LuxCoder
how do i test the return value of my Update method?
It's just a function like any other. How do you normally test the return value of a function?
Re: Datagridview update not working