C # dataset class

Source: Internet
Author: User

Dataset is one of the core members of ADO. NET and is also the most frequently used class for developing database applications based on. NET platform programming languages.Each dataset has multiple Ables and relationships.Relationship should also be a type of table. In particular, this table is only used to associate two data tables. Each able has many datarows and datacols,
It also includes parentrelations, childrelations, and restrictions that the primary key cannot be repeated.

Each row of dataset has a rowstate attribute. It mainly indicates whether the current row has been deleted, updated, or not. There are several options: deleted, modified, new, and unchanged.

Any operations on dataset are completed in the computer cache.
After data is extracted from the database, dataset is the data storage location.It is the cache mapped to data from various data sources in the computer memory, so sometimes dataset can be considered as a data container.
A DataSet object is a data view that can be expressed in XML format. It is a data relationship view.

Dataset is generally used in three ways:
1. Fill in dataset with the data in the database through the dataadapter object
The dataadapter dataset filling process consists of two steps: first, retrieve the required data from the database through the sqlcommand attribute of dataadapter. Sqlcommand is actually a command object. Then, the retrieved data is filled with dataset through the fill method of dataadapter.

2. update the database through dataset operations on the dataadapter object
Dataadapter uses its update method to update the database with data in dataset. When the data contained in the dataset instance is changed, call the update method. dataadapter analyzes the changes and runs the corresponding commands (insert, update, or delete ), and use this command to update the data in the database.

3. load XML data streams or text to Dataset
Data in dataset can be created from XML data streams or documents. Loading XML data streams and documents to dataset is a readxml method that can use dataset objects.

Data BindingTwo types: simple data binding and complex data binding. Simple data binding components include lable and Textbox, and complex data binding components include DataGrid, ListBox, and ComboBox.

Simple data binding generally uses the Add method of the databindings attribute in these components to bind a row in a able in the dataset with a property of the component to display data.

For example, textbox1.databindings. Add ("text", dsdataset1, "MERs. customerid ");

Complex data binding generally sets the datasource attribute and displaymember attribute of the component to complete data binding. The datasource attribute value is generally set to the dataset to be bound, and the displaymember attribute value is generally set to the data table or a column in the data table to be bound.
For example, datagrid1.datasource = dsdataset1;
Datagrid1.datamember = "MERs ";

Dataset attributes can be tablesGet the number of tables in the dataset: DataSet. Tables. Count

Dataset tables is a table array,Specify a table: DataSet. Tables [I]; // I is

Position of the table in the array sequence or dataset. Tables ["table name"];


Use the count of the table's rows object groupObtain the number of records for the table: DataSet. Tables [I]. Rows. count;

Obtain the number of columns: DataSet. Tables [I]. Columns. count;


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.