|
-
Nov 27th, 2009, 08:01 AM
#1
Thread Starter
Hyperactive Member
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
-
Nov 27th, 2009, 08:31 AM
#2
Addicted Member
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.
-
Nov 27th, 2009, 10:03 AM
#3
Thread Starter
Hyperactive Member
Re: Datagridview update not working
alright, even after removing it the changes are not affecting the DB
-
Nov 28th, 2009, 05:35 AM
#4
Thread Starter
Hyperactive Member
Re: Datagridview update not working
-
Nov 28th, 2009, 08:48 AM
#5
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.
-
Dec 6th, 2009, 03:29 AM
#6
Thread Starter
Hyperactive Member
Re: Datagridview update not working
how do i test the return value of my Update method?
-
Dec 6th, 2009, 05:00 AM
#7
Re: Datagridview update not working
 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?
-
Dec 6th, 2009, 08:39 AM
#8
Thread Starter
Hyperactive Member
Re: Datagridview update not working
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|