Implementing data binding for Windows programs

Source: Internet
Author: User

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

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.