|
-
Sep 14th, 2019, 02:22 PM
#1
Thread Starter
Fanatic Member
DataAdapter.Update method
As per Microsoft's documentation, there are several ways to call the DataAdapter.Update method by passing it one of the following: an array of DataRow objects, a DataSet object, or a DataTable object.
And furthermore, the AcceptChanges method for the DataRow, DataSet, or DataTable should also be implicitly called by the DataAdapter.Update method.
I have a MS Access database as my datasource. I use a DataAdapter and I've configured its DeleteCommand, InsertCommand, and UpdateCommand properties.
If I call the DataAdapter.Update method and pass it a DataTable, the AcceptChanges method of the DataTable is not implicitly called by the DataAdapter.Update method.
Code:
dtTemp = dsMain.Tables("Categories").GetChanges(DataRowState.Modified)
daCategories.Update(dtTemp)
If instead I call the DataAdapter.Update method and pass it an array of DataRow objects, then the AcceptChanges method for each changed DataRow is implicitly called by the DataAdapter.Update method.
Code:
rows = dsMain.Tables("Categories").Select(vbNullString, vbNullString, DataViewRowState.ModifiedCurrent)
daCategories.Update(rows)
I can see this behavior by checking the if the DataTable has changes before and after calling the DataAdapter.Update method.
Code:
Debug.Print(dsMain.Tables("Categories").GetChanges Is Nothing)
Since the Microsoft documentation claims otherwise, is there something that I'm missing?
Last edited by Mark@SF; Sep 14th, 2019 at 02:58 PM.
Tags for this Thread
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
|