VS. NET (C #) database interface-Description of DataColumn and DataRow objects, vs.net

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.