Introduction to ADO. NET object Connection, Command, DataReader, DataAdapter, DataSet, and DataTable in Winform Development,

Source: Internet
Author: User

Introduction to ADO. NET object Connection, Command, DataReader, DataAdapter, DataSet, and DataTable in Winform Development,

The ADO. NET technology mainly includes six objects, including Connection, Command, DataReader, DataAdapter, DataSet, and able. The following describes these six objects:
(1) The main function of the Connection object is to connect to the database (this object is also used for transaction processing ).
(2) The Command object is mainly used for database commands that return data, modify data, run stored procedures, and send or retrieve parameter information.
(3) The main function of the DataReader object is to read rows from data in the stream-only mode.
(4) The main function of the DataAdapter object is to fill the content in the database into the DataSet object. After modifying the data in the DataSet object
You can also notify the database of the modified information so that the data in the DataSet object is consistent with the data in the database.
(5) DataSet objects are the core concepts of ADO. NET. They are the core objects supporting ADO. NET disconnected and distributed data solutions.
A DataSet object is a database container that can be used as a database that exists in the memory. No matter what the data source is, it provides a consistent relational programming model.
(6) DataTable can be understood as a data table in memory.

It visually illustrates the role of each object in ADO. NET.
(1) databases can be compared to reservoirs, storing a large amount of data.
(2) The Connection object can be compared to entering the water cage. Only after opening the water cage can the water be drawn.
(3) The Command object can be compared to a water pumping machine. The water will be sent to the user's home after it is opened into the water tank.
(4) The DataReader object can be compared to a water pipe, which can be opened into the water cage and then the water pumping machine. The water will be sent to the user's home.
(5) The DataAdapter object can be compared to a water pipe. Open the water tank and use its own engine to pump water. The water will be sent to its own water yard for storage for future use.
(6) DataSet objects can be compared to tap water. When the tap water field is filled with water pumps, even if the tap water is turned off (disconnected from the database), the tap water field can still be used with water.
(7) The DataTable object can be compared to the pool in the tap water yard. The tap water yard consists of many pools.

From C # related books

ADO. NET allows you to create a able object and add it to an existing DataSet. You can use the PrimaryKey and Unique attributes to set constraints for the DataTable.

DataSet customerOrders = new DataSet("CustomerOrders");DataTable ordersTable = customerOrders.Tables.Add("Orders");DataColumn pkOrderID =     ordersTable.Columns.Add("OrderID", typeof(Int32));ordersTable.Columns.Add("OrderQuantity", typeof(Int32));ordersTable.Columns.Add("CompanyName", typeof(string));ordersTable.PrimaryKey = new DataColumn[] { pkOrderID };

Case Sensitive

DataSet can contain two or more tables with the same name but different cases or relationships. In this case, table and Link References by name are case sensitive. For example, if DataSetDataSetInclude tableTable1AndTable1,Table1AsDataSet. Tables ["Table1"]To referenceTable1AsDataSet. Tables ["table1"]. If you try to use any of the tablesDataSet. Tables ["TABLE1"].

If there is only one table or link with a specific name, Case sensitivity is not applicable. For example, if DataSet only containsTable1, You can useDataSet. Tables ["TABLE1"].

 

Related Article

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.