bradmq
asked on
VB.NET Dataset doesn't seem to update actual data source
I have the following code:
objAdapter.Fill(objDataSet )
...
objDataSet.Tables("Table") .Rows(Row) .BeginEdit ()
objDataSet.Tables("Table") .Rows(Row) .Item("Tim eAccumulat or") = objDataSet.Tables("Table") .Rows(Row) .Item("Tim eAccumulat or") + PingRate
objDataSet.Tables("Table") .Rows(Row) .EndEdit()
...
objDataSet.AcceptChanges
Dim oCB As OleDbCommandBuilder = New OleDbCommandBuilder(objAda pter)
objAdapter.Update(dsModifi ed)
which runs without any errors, but the data source (i have tried both MS Access 2002 and SQL 2000) does not get updated.
I know that the dataset has my changes in it because I have called the objDataSet.GetXML method and written the XML to the event log and I can see my changes.
What am I missing?
objAdapter.Fill(objDataSet
...
objDataSet.Tables("Table")
objDataSet.Tables("Table")
objDataSet.Tables("Table")
...
objDataSet.AcceptChanges
Dim oCB As OleDbCommandBuilder = New OleDbCommandBuilder(objAda
objAdapter.Update(dsModifi
which runs without any errors, but the data source (i have tried both MS Access 2002 and SQL 2000) does not get updated.
I know that the dataset has my changes in it because I have called the objDataSet.GetXML method and written the XML to the event log and I can see my changes.
What am I missing?
ASKER
Whoops,
I posted code between edits. The line should actually read
objAdapter.Update(objDataS et)
I had had some code previously that looked like this:
Dim dsModified As New DataSet()
dsModified = objDataSet.GetChanges
then I was calling
objAdapter.Update(dsModifi ed)
This didn't work either so I had simplified it to just passing the dataset to the Update method.
Brad
I posted code between edits. The line should actually read
objAdapter.Update(objDataS
I had had some code previously that looked like this:
Dim dsModified As New DataSet()
dsModified = objDataSet.GetChanges
then I was calling
objAdapter.Update(dsModifi
This didn't work either so I had simplified it to just passing the dataset to the Update method.
Brad
Those are supposed to be parens and not brackets...
Ignore that post please...wrong window.
ASKER
I figured out the problem:
The Update method on the adapter has to be called before the Acceptchanges method on the dataset!
Seems stupid and counter intuitive but I guess if I needed to rollback, I could call dataset.rejectchanges and call the adapter.update method again.
The Update method on the adapter has to be called before the Acceptchanges method on the dataset!
Seems stupid and counter intuitive but I guess if I needed to rollback, I could call dataset.rejectchanges and call the adapter.update method again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
--M