Update Dataset with Access

  • Thread starter Thread starter Percy NG
  • Start date Start date
P

Percy NG

Hi,
I used OleDb.OleDbDataAdapter to retrive and modify the access
i used merge function to combin another dataset, then update Access DB
but i can't update the database by using pDataAdapter.Update(ds_data)
the result is always 0

Here is my code
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
pDataAdapter.SelectCommand = New OleDb.OleDbCommand(Sql, mConn)
pDataAdapter.Fill(ds_data)

Dim Key1() As DataColumn = {ds_data.Tables(0).Columns("item"),
ds_data.Tables(0).Columns("desc")}
ds_data.Tables(0).PrimaryKey = Key1
ds_data.AcceptChanges()
ds_data.Merge(datainfo, True, MissingSchemaAction.AddWithKey)
pDataAdapter.Update(ds_data)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''
I am not sure what is problem, any suusgestion for updating Access with
dataset ???

Thanks
Percy
 
Percy,

I just had this problem. When you call AcceptChanges, all of the rowstates
are set to unchanged. After this call, none of the records will be updated
in the DataAdapter.Update call.

HTH

Brad
 
Percy,

In addition to Brad. The acceptchanges does if all changes are done, and
therefore as Brad said, set the rowstates to unchanged while the changes are
accepted. (They are not set back in the original state)

Cor
 
Back
Top