VS. NET (C #) Database Interface: DataSet object description, vs.net

Source: Internet
Author: User

VS. NET (C #) Database Interface: DataSet object description, vs.net

The object model of DataSet is as follows:

DataSet objects include: DataTableCollection type and DataRelationCollection type:

DataTableCollection is a collection of able objects and serves as the Tables attribute of DataSet objects.

DataRelationCollection is a collection of DataRelation objects.

DataTable objects include: DataColumnCollection type and DataRowCollection type:

DataRowCollection is a collection of DataRows objects and serves as the attribute of its Columns. This column set defines the structure of the table.

DataSet Constructor

DataSet () initializes a new instance of the DataSet class

New DataSet (String) instance initializes a class with a given name for DataSet.

DataTable common attributes

(1) TableName: used to obtain or set the name of the DataTable.

(2) DataSet: used to indicate the DataSet from which the DataTable belongs.

(3) Rows: indicates the set of DataRow objects of the DataTable, that is, the records used in the corresponding data table. The programmer uses this attribute to access each record in the DataTable in sequence. This attribute has the following methods.

Add: append the row created by the AddRow method of DataTable to the end.

InsertAt: append the row created by the AddRow method of DataTable to the position specified by the index number.

Remove: deletes the specified DataRow object and physically deletes the corresponding data from the data source.

RemoveAt: deletes data based on the index number.

(4) Columns: used to represent the set of DataColumn objects of the DataTable. With this attribute, each field in the DataTable can be accessed in sequence.

Common DataTable Methods

① DataRow NewRow () method: This method is used to add a new row to the current able and return the DataRow object indicating the row record. However, this method does not add the created DataRow to the DataRow set, instead, you must call the Add method of the Rows attribute of the DataTable object to complete the Add action.

② DataRow [] Select () method: After this method is executed, an array composed of DataRow objects is returned.

③ Merge (DataTable table) method: This method can Merge the DataTable and the able in the parameter.

④ Load (DataReader reader) method: This method loads data from the corresponding data source into the DataTable through the IdataReader object in the parameter for subsequent operations.

⑤ Clear () method: This method is used to Clear data in a able. It is usually called before obtaining data.

⑥ Reset () method: This method resets the abl object with.

The table is as follows:

Method Name

Return type

Description

AcceptChange

Void

All changes made to the DataSet object after the DataSet object is submitted or after the AcceptChanges () method is last called

Clear

Void

Remove all rows from all tables to clear DataSet of any data.

Clone

DataSet

Copy the DataSet structure, including all the able architectures, relationships, and constraints. Do not copy any data.

Copy

DataSet

Copy the structure and data of the DataSet object

GetChanges

DataSet

Get a copy of the DataSet object. The copy contains all changes made to the DataSet since the last loading or since the AcceptChanges () method is called.

GetXml

String

Returns the XML Representation of the data stored in the DataSet object.

GetXmlSchema

String

Returns the XML Representation of the data stored in the DataSet object. XSD Schema

HasChanges

Boolean

Gets a value indicating whether the DataSet object has been changed, including new rows, deleted rows, or modified rows.

Merge

Void

Merges the array of the specified DataSet, able, or DataRow object into the current DataSet or DataTable object.

ReadXml

XmlReadMode

Read XML schema and data into DataSet object

ReadXmlSchema

Void

Read the XML schema into the DataSet object

RejectChanges

Void

Cancels all changes made to the DataSet object since the DataSet object is created or since the AcceptChanges () method was last called.

Reset

Void

Resets A DataSet object to its initial state. The Child class should override the Reset object to restore the DataSet object to its original state.

WriteXml

Void

This method is used to write XML data from a DataSet object. You can also select a write architecture.

WriteXmlSchema

Void

Write the DataSet structure in XML format


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.