Use of DataSet classes in C #

Source: Internet
Author: User
use of DataSet classes in C # The DataSet class is one of the most central members of the Ado.net, and it is the most frequently contacted 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, in particular, this table is only used to contact two data tables. Each DataTable has a lot of datarows and Datacols, and also includes parentrelations,childrelations and restrictions like primary keys that cannot be duplicated.         dataset each row has a RowState property. The main is to reflect whether the current line has been deleted, has been updated, or did not change. There are several options:   deleted, Modified, New, and unchanged.          Any operation of the dataset is done in the computer cache.        after data extraction from the database, the dataset is the repository of data, which is the cache of data in various data sources mapped into computer memory. So it is sometimes said that a dataset can be considered a data container. A DataSet object is a data view that can be represented in XML, and is a view of data relations. There are three kinds of methods used in       dataset:     1. Populate the DataSet with the data from the database through the DataAdapter object     dataadapter the process of populating a dataset is divided into two steps: first retrieving the required data from the database through the DataAdapter SqlCommand attribute. SqlCommand is actually a command object. The retrieved data is then populated with the dataset using the DataAdapter Fill method.       2. Update database with DataAdapter object manipulation DataSet      DataAdapter is implemented through its Update method to DatasET data to update the database. When the dataset instance contains data changes, the Update method is called, and DataAdapter analyzes the changes made and executes the appropriate command (INSERT, update, or DELETE) and updates the data in the database with this command.       3. Data that loads XML data streams or text into the 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. Suitable for simple data binding components generally have lable, textbox, etc., suitable for complex data binding components generally have DataGrid, ListBox, ComboBox, etc.   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 display data.   For example: TextBox1.DataBindings.Add ("Text", DsDataSet1, "Customers.") CustomerID ");        complexity data binding typically sets the component's DataSource properties and DisplayMember properties to complete data binding. The DataSource property value is generally set to the value of the Dataset,displaymember property to bind to a column in the datasheet or datasheet to bind. For example: DataGrid1.DataSource = DsDataSet1; DataGrid1.DataMember = "Customers"; The properties of the   dataset you can get the number of tables in the dataset: the tables of the DataSet.Tables.Count   dataset are a table array, Specifies one of the tables: dataset.tables[i];//i is the position of   table in the array sequence or the dataset.tables["table name"];  &NBsp Gets the number of records for the table by count of the Rows object Group in table: Dataset.tables[i]. Rows.Count;   Get 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.