DataRow's status

xiaoxiao2021-03-06  79

The flying fish answering on the jar, it is very meaningful, records Dataset.Table.Rows [x]. Delete (), there is still in the DataTable, just the state change, even after Update should be .acceptchanges () If you want to use this DataSet.Table description After the following DataRow object is just created, its status is detached, is an isolated one existence, so after the DataRow is created, the unit in DATAROW is filled with data, but also passed DataTable.Rows.Add (DATAROW) After adding this DATAROW to DataTable, after DATAROW is added to DataTable, the status of this DATAROW is converted to Added. When this DATAROW is modified, this DATAROW status is converted to modified. When DataRow.delete () method is deleted, the DATAROW status will be turned to deleted, but this line still exists in the DataTable, but the state changes, at this time Use DataTable.Rows.count to view the number of rows, before the deletion is the same. This DATAROW is only removed from the DataTable and the status is also removed from the DataTable.Remove (DataRow) method.

Once the DataTable.AcceptChanges () method is called, all rows will do different processing, add, modified, unchange according to different states, and the DELETED's line will be removed from the DataTable, and the status of all rows are set. To unchanged. When DataTable is formed from a DataAdapter.Fill (DataSet, DataTable) method, the Fill () method will automatically call the AcceptChanges () method, set the DataTable's row status to unchanged. And, if the DataTable specified in the Fill method does not exist when the Dataset to be filled, a DataTable with the same structure as the data source table is generated and populated.

转载请注明原文地址:https://www.9cbs.com/read-107360.html

New Post(0)