Updating records in dataset
The BDE considers any SQL join to be read-only because inserting, updating, and deleting rows in a join is ambiguous.For example, should the insert of a row into the previous join result in a new product and also a new supplier, or just a new product?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.
After that I assign values of the row and call the Data Adapter's Update method. Updating data using the Data Adapter's Update method Deleting a row is simple.
If you update a field in the Products table and post the change, then a SQL statements are generated, one for each table.
The order in which the statements are executed is important, because the new product might relate to the new supplier, so the new supplier is inserted first.
Note: The Tables member of Data Set represents all Data Table objects attached to a Data Set. Adding a Data Row to a Data Table Dim row1 As Data Row = ds. To test this source code create a Windows application, drop a Data Grid, and three buttons- Insert Command, Update Command, and Delete Command to the form.
Listing 5-46 Creates a new Data Row, sets the data of Data Row members, and adds rows to the table using the Add method of Data Table. Listing 5-48 show the code on the Insert Command button-click event.
After that I called the Data Adapter's Update method to save the changes to the database table.