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 #