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

Re: Update Dataset with Access by Brad

Brad
Wed Sep 29 14:41:51 CDT 2004

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 NG" <percy_ng@hotmail.com> wrote in message
news:eAuYdYkpEHA.3868@TK2MSFTNGP15.phx.gbl...
> 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
>
>



Re: Update Dataset with Access by Cor

Cor
Thu Sep 30 10:32:31 CDT 2004

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