Many beginners of C # programming or asp.net will be exposed to Connection objects, Command objects, DataAdapter objects, DataSet objects, and DataReader objects, which constitute ADO. NET, which is used for Web/WinForm data interaction. (This article is written for beginners. If you have any questions, please contact Me or Mail Me. Please give Me more advice) here we need to talk about the word "Data Interaction". In fact, the literal meaning of interaction must be a mutual process. It is a metaphor that you need to interact with the boss of a fast food restaurant to buy food at a fast food restaurant. First of all, you have to say hello to your boss, as a metaphor: "The boss has a fish-flavored shredded pork covered rice bowl. Do you have it ?", The boss will tell you, "okay, yes, you can pack it and eat it here "...... A few words are omitted in subsequent scenarios. First, let's say hello to the boss. What is the process of data interaction in our Web/WinForm? That is, the key phrase for opening the interaction. At the beginning of the Data interaction, we must open the door of the Data Server through the Connection object, this includes the User Id, Password, DB Name and as so on of the Data Server. and then, when you get home, you ask the boss's command to "Add fish-flavored shredded meat And rice". At this time, you sent a request command to the DB Server, in SQL Server, this command generally includes basic commands such as select, insert, delete, and update. If you enjoy your "fish-flavored shredded rice bowl", then your stomach acts as a DataSet, if you pack and take it away, it is convenient to bag (but your stomach is the last place to store it); the process of communicating with your boss is equivalent to ADO. NET DataReader process; when the boss prepares your meals, the analogy is put on the table of his restaurant, and you are watching the NBA game, at this time, the table in the restaurant serves as the DataAdapter object and also plays this role. I do not know whether the above-mentioned scenes are consistent with the five specific object application scenarios. Thank you for your comments and corrections. Next, let's take a look at the functions of the above five objects! The Connection object is mainly used to enable the Connection between the program and the database. You cannot obtain data from the database if you do not use the linked object to open the database. This object is at the bottom layer of ADO. NET. We can generate this object by ourselves or automatically generate it by other objects. The Command object can be used to send commands to the database, such as sending query, addition, modification, and deletion commands to the database, as well as calling the stored programs in the database. This object is structured on the Connection object, that is, the Command object is connected to the data source. DataAdapter object: The DataSetCommand object transfers data between data sources and DataSet. It can place the obtained data into the DataSet object after issuing a Command through the Command object. This object is structured on the Command object and provides many functions used with DataSet. In Beta 2, The DataSetCommand object is renamed as DataAdapter. The DataSet object can be regarded as a Cache, which can keep the data queried from the database and even display the whole database. DataSet can not only store multiple tables, but also obtain data Table structures such as primary keys through the DataSetCommand object and record the association between data tables. The DataSet object can be called ADO. NET heavyweight object, which is structured on the DataSetCommand object and does not have the ability to communicate with the data source itself. That is to say, we use the DataSetCommand object as a DataSet object and a bridge between data sources for data transmission. The DataReader object can be used when we only need to read data sequentially without other operations. The DataReader object only reads data from the data source in a descending order, and the data is read-only and does not allow other operations. Because DataReader only reads one row at a time and can only be read-only, it not only saves resources but also improves efficiency. In addition to high efficiency, DataReader can reduce network load because it does not need to transmit all data. Connection object code: www.2cto. comOLEDB: OleDbConnection MyConnection = new OleDbConnection (); SQL: SqlConnection MyConnection = new SqlConnection (); Oracle: OracleConnection ocn = new OracleConnection (); ◆ ConnectionString attribute: Get or set a connection statement. MyConnection. connectionString = "server = (local); database = pubs; uid = sa; pwd ='' "; ◆ DataBase attribute: Get the currently opened database ◆ DataSource attribute: obtain the connection instance for opening the database ◆ Open method: Open the connection ◆ Close method: Close the connection