Use of the DataSet class in C #

Source: Internet
Author: User

The DataSet class is one of the most core members of ADO, and is the most frequently exposed class for developing database applications based on the. NET Platform programming language. Each dataset has a lot of datatables and relationships. Relationship should also be a kind of table, especially, this table is only used to contact two data tables. Each DataTable has many DataRows and Datacols, and also includes parentrelations,childrelations and some restrictions like the primary key cannot be repeated.        dataset each row has a RowState property. Mainly reflects whether the current line has been deleted, has been updated, or has not changed. There are several options:   deleted, Modified, New, and unchanged.         any operation on the dataset is done in the computer cache.        after data extraction from the database, the dataset is the place where the data is stored, which is a cache of data from various data sources mapped in the computer's memory. So sometimes a dataset can be thought of as a data container. A DataSet object is a data view that can be represented in XML, a data relationship view. There are three ways to use      dataset:     1. Populate a DataSet with data from a database by DataAdapter objects     dataadapter Populating a DataSet is a two-step process: First retrieving the required data from the database through the DataAdapter SqlCommand property. SqlCommand is actually a command object. The retrieved data is then populated with the dataset using the DataAdapter Fill method.      2. Updating the database with the DataAdapter object operation DataSet      DataAdapter is implemented by its Update method to update the database with data in the dataset. WhenWhen a dataset instance contains data changes and the Update method is called, DataAdapter parses the changes made and executes the corresponding command (INSERT, update, or DELETE) and updates the data in the database with this command.      3. Data that is loaded into an XML stream or text into Dataset    dataset can be created from an XML data stream or document. Loading XML data streams and documents into a dataset is a ReadXml method that can use a DataSet object.        data binding is divided into two categories: simple data binding and complex data binding. For simple data binding components generally have lable, textbox, etc., for the complexity of data binding components generally have a DataGrid, ListBox, ComboBox and so on.   Simple data binding typically uses the Add method of the DataBindings property in these components to bind a row in a DataTable in a dataset to a property of a component to achieve the effect of displaying the data.   such as: TextBox1.DataBindings.Add ("Text", DsDataSet1, "Customers. CustomerID ");      complex data binding is typically the DataSource property of the set component and the DisplayMember property to complete the data binding. The DataSource property value is typically set to the value of the Dataset,displaymember property to bind to a column in the data table or datasheet that you want to bind. For example: DataGrid1.DataSource = dsDataSet1;d atagrid1.datamember = "Customers";  The dataset's properties Tables can get the number of tables in the dataset: Dataset.tables.count dataset's Tables is a table array that specifies one of the tables: Dataset.tables[i ];//i for  table in the array sequence or dataset.tables[table name];   the number of records for the table through the count of rows in table's group:Dataset.tables[i]. rows.count;  gets the number of columns: dataset.tables[i]. Columns.count;

Use of DataSet classes in C #

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.