|
Subject:
|
How to Add/Delete/Update multiple records in DB?
|
|
Posted By:
|
mmwaikar
|
Post Date:
|
7/31/2003 4:42:54 PM
|
Hi All,
In a Master Details form, a user can modify multiple rows in the details grid. e.g. in a typical Invoice - Invoice Details scenario, where Invoice Details are shown in a grid, the user may add some rows, delete some rows and modify some rows.
My Q. is -- how to reconcile these changes to the database ?
Because uptil now, I was using the DataAdapter and setting various parameters (like InsertCommand.Parameters.Add or UpdateCommand.Parameters.Add ...) but by this, we can only add / update / delete a single record.
Please help.
Thanks and Regards, Manoj Waikar.
|
|
Reply By:
|
bani
|
Reply Date:
|
9/20/2003 11:41:50 AM
|
Make use of the DataAdapter.Update() method which can accept DataTable or DataSet as a constructor arguement. The DataAdapter will examine the DataTable or DataSet for any changes and it will update the database by batch. This assumes that you already defined your updating logic in the DataAdapter's SelectCommand, UpdateCommand, DeleteCommands, InsertCommand properties. All this properties accept/return Command objects which you are already comfortable working with.
|
|