Updating an access file using c
As you can see from listing 5-48, I created a filled Data Set and created a new Data Row using the Data Table. After creating a Data Row, I set its column values and called the Data Adapter's Update method and displayed data in the Data Grid.
I added new rows to the Customers table with Customer Id, Customer Name, and Company Name (named Tst ID, Lana Jackob, and Mindcracker Inc., respectively). Adding data using a Data Adapter's Update method Listing 5-49 shows an example that edits row data.
The way the architecture works with the Data Adapter is that you can make any changes you want to the filled Data Set, and it won't affect the database until you call the Update method.
When Update is called, the Data Adapter will attempt to execute each query (UPDATE, INSERT, DELETE) on every row of the Data Set that has been updated, inserted, and deleted.
As you saw in the Data Table, Data Row, and Data Column sections at the beginning of this article, you can use the Delete method of a Data Row to delete a row.
The Add New method of the Data Table adds a row to a Data Table.
To save data to the data source, you need to call the Data Adapter's Update method.
To insert, update, and delete data using a Data Adapter, you create an Ole Db Command object with INSERT, UPDATE, and DELETE statements and set the Insert Command, Update Command, and Delete Command properties of the data adapter to Ole Db Command.