G
Guest
OK, I hate myself for asking this, it's the worst question I have ever asked
but it's worse not to ask:
¿How do I update a datatable in vs 2005? I mean, I am using a typed dataset,
a datagridview control and SQL express. I tried this code on a separate
button to commit changes to the database:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdOK.Click
If Not Me.DataSet.DataTable.GetChanges Is Nothing Then
Me.DataTableTableAdapter.Update(Me.DataSet.DataTable.GetChanges)
End If
End Sub
It seems to work fine, no exception is thrown, the update method returns 1,
the datagridview shows just the right modified data, and if I clear the
dataset and fill it again with the tableadapter it keeps the same data. But
it's not working, when I open this SQL Express datatable from the visual
studio server explorer it has the original unedited data and I can't change
that.
I have event tried to run a simple sqlcommand with an insert query, but I
get the same results. Am I doing anything wrong? Maybe I must configure
something on SQL Express or in VS? Call some method of the dataset, the
tableadapter, the bindingsource or the datagridview before changes can be
sent to the database?
Just to add some more info, I tried to update, insert and delete data from
the Server Explorer and it works fine.
but it's worse not to ask:
¿How do I update a datatable in vs 2005? I mean, I am using a typed dataset,
a datagridview control and SQL express. I tried this code on a separate
button to commit changes to the database:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdOK.Click
If Not Me.DataSet.DataTable.GetChanges Is Nothing Then
Me.DataTableTableAdapter.Update(Me.DataSet.DataTable.GetChanges)
End If
End Sub
It seems to work fine, no exception is thrown, the update method returns 1,
the datagridview shows just the right modified data, and if I clear the
dataset and fill it again with the tableadapter it keeps the same data. But
it's not working, when I open this SQL Express datatable from the visual
studio server explorer it has the original unedited data and I can't change
that.
I have event tried to run a simple sqlcommand with an insert query, but I
get the same results. Am I doing anything wrong? Maybe I must configure
something on SQL Express or in VS? Call some method of the dataset, the
tableadapter, the bindingsource or the datagridview before changes can be
sent to the database?
Just to add some more info, I tried to update, insert and delete data from
the Server Explorer and it works fine.