Marco,
Basically to accomplish this, all what you need to do is create an instance of the CommandBuilder Object (SqlCommandBuilder or OleDbCommandBuilder, etc..) and pass
the DataAdapter object that you used to fill the Dataset. This will build all the three needed commands to update your data (Update, Insert and Delete commands). As sson
as you modify the data in the DataGrid, just call the DataAdapter.Update and pass in the DataGrid.DataSource as an argument. You could pass the DataSet.Table directly
to the Update method. Now, the DataAdapter will scan all the rows in the DataTable and based on the RowState property (that is set automatically based on what you have
done to the data i nthe datagrid) and decide to call the proper command that matches that property. For example, if the RowState is "Deleted" then it calls the
DeleteCommand and sts all the needed parameters for that command from that data row. The same applies for other RowStates except "Unchanged" state where it just
skips that row.
I hope this helps!
Thanks,
Hussein Abuthuraya
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.