Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatable.acceptchanges() commits data to the table

Datatable.acceptchanges commits data to the table...means

will it insert data to the table ..or datatable?

like image 368
SmartestVEGA Avatar asked Apr 19 '11 18:04

SmartestVEGA


People also ask

What does AcceptChanges do?

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.

How do I view a DataTable?

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.

Which namespace is used for DataTable?

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.


2 Answers

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.

like image 86
Katie Kilian Avatar answered Oct 08 '22 11:10

Katie Kilian


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.

like image 37
Adam Rackis Avatar answered Oct 08 '22 11:10

Adam Rackis