VS. NET (C #) database interface-Description of DataColumn and DataRow objects, vs.net
1) DataColumn object
In DataTable, The DataColumn object is used to describe the fields of the corresponding data table, and the DataRow object is used to describe the records of the corresponding database.
It is worth noting that the DataTable object generally does not modify the table structure, so it only reads columns through the Column object.
Common attributes of a DataColumn object are as follows.
Caption attribute: used to obtain and set the column title.
ColumnName attribute: used to describe the name of the DataColumn in DataColumnCollection.
DataType attribute: describes the data types stored in this column.
2) DataRow object
In DataTable, DataRow objects are used to describe the records of the corresponding database. The DataRow object is similar to the Rows attribute in the DataTable object and is used to describe the records in the DataTable object.
But in ADO. "Raw data" and "updated data" of DataRow under. In addition, the modified data in DataRow cannot be instantly reflected in the database, data can be updated only when the DataSet Update method is called.
An important attribute of a DataRow object is the RowState attribute, which indicates whether the DataRow is modified or not. The value of the RowState attribute can be Added, Deleted, Modified, or Unchanged.
You can set the RowState attribute of the current DataRow object by using the following methods:
VoidSetAdded ();
VoidSetModified ();
The DataRow object also has the following important methods:
① Void AcceptChanges () method: This method is used to submit all modifications to this row to the database after the last AcceptChanges method is executed.
② Void Delete () method: This method is used to Delete the current DataRow object.
③ Void BeginEdit () method: This method is used to edit a DataRow object.
④ Void cancelEdit () method: This method is used to cancel the editing operation on the current DataRow object.
⑤ Void EndEdit () method: This method is used to terminate the editing operation on the current DataRow object.