First, DataSet: DataSet
in System.Data
1. In-Memory staging database
2. Separate from the database
The DataSet contains:
multiple tables, with rows and columns in the table
To create a data set:
DataSet Ds=new DataSet ();//similar to temporary warehouse
Populate data:
data adapter: dataadapter//; similar to delivery truck
usage of data adapter DataAdapter
1. Create a Connection object: similar to paving between temporary and warehouse
Connection Object Usage
2. Create SQL statement (query statement): To get the data (goods to be pulled by the delivery truck)
3. Create a DataAdapter object: Apply for a truck
DataAdaPter da=new DataAdaPter (SQL,CN)
4. Populate the data set:
da. Fill (DS);//unloading
Execute, open database connection, query data, populate data set, close connection
Second, Datagradview: can display multi-row multi-column data
Properties:
1.dataSouece: Binding Data Source
2.Columns: Add columns:
HeaderText: Setting column headers
dataproperyname: Facilities column Data
3.SelectionMode: Set Check mode
Disconnect the new data from the environment:
You must set the DataAdapter command to delete or change:
InsertCommand:
UpdateCommand:
DeleteCommand:
can be automatically generated according to Dataapter's SelectCommand
automatic Generation Method:
sqlcommandbuilder cmd=new SqlCommandBuilder (DA);
Note: Primary key columns must be in SelectCommand
2. Updating Data
da. Update (ds[, table name])
DS datasets are data sources that are bound to Datagraidview
Implementing data binding for Windows programs