Datatable.acceptchanges commits data to the table...means
will it insert data to the table ..or datatable?
When AcceptChanges is called, any DataRow object still in edit mode successfully ends its edits. The DataRowState also changes: all Added and Modified rows become Unchanged , and Deleted rows are removed.
You can access the contents of a DataTable by using the Rows and Columns collections of the DataTable. You can also use the Select method to return subsets of the data in a DataTable according to criteria including search criteria, sort order, and row state.
DataTable is part of the System. Data namespace. We add, select and iterate over stored data. The foreach-loop can be used on the Rows in a DataTable.
The purpose of AcceptChanges() is to let the DataTable know that its data has been saved to the database. All DataRows in the DataTable have their row.RowState set to DataRowState.Unchanged.
It does not save the data to the database. That is done separately.
Here's the documentation:
When AcceptChanges is called, any DataRow object still in edit mode successfully ends its edits. The DataRowState also changes: all Added and Modified rows become Unchanged, and Deleted rows are removed.
The AcceptChanges method is generally called on a DataTable after you attempt to update the DataSet using the DbDataAdapter.Update method.
So your actual database is unaffected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With