In terms of concept, ADO. Net defines an object-oriented class library that interacts with data sources. A class library is a collection of classes. That is to say, ADO. Net mainly provides some classes and interfaces for interaction with data sources.
In my opinion, ADO. Net defines a set of interfaces for accessing data sources. The interface is mainly used to specify specifications for others to implement, but it is not implemented by itself. When we are working on a data center charging system project, the sqlconnection, sqlcommand, and so on are just some classes that implement interfaces for SQL Sever.
Ado. Net mainly includes the following objects:
The following describes the relationships between them:
1. The connection object is the most underlying object in ADO. net, mainly the connection bridge between programs and data. The connection object has two attributes: connectionstring, open database connection string, and state, database connection status, mainly including open and close.
Method: open () Open the database connection close () Close the database connection
Note: whether the database is connected is a prerequisite for ensuring other objects.
2. The command object is mainly used to execute SQL commands for adding, deleting, modifying, and querying data, or to execute stored procedures. However, when executing the stored procedure, you must set the command attribute to command. storedprocedure. When executing the SQL statement, set it to commandtype. Text.
Main method: excutenonquery (): Execute an SQL statement and return the affected number of rows. It is mainly used for adding, deleting, and modifying operations, but not for query. Excutereader (): executes an SQL statement and returns datareader.
Excutescalar (): Retrieves a single value, mainly used for statistical operations.
3. datareader object: it is a read-only method for reading rows. Generally, it reads a single record. Generally, the performance is higher than that of dataadapter, but dataadapter returns multiple records, for example, if we usually use the dategridew control to bind data, we often use dataadapter to return a datatable.
4. dataadapter object: The data retrieved from the data source is sent to dataset for storage by executing the command operation using the connection object. It is mainly filled by the fill () method, update () method.
5. dataset objects: including datatable and datagridew objects, mainly responsible for managing data stored in memory and disconnecting operations.
6. datatable object, which is a virtual table in dataset, including data rows and columns. You can obtain a specified record from a data row, define the data type, size, and set whether to be null, primary key, read-only, and other attributes from the data column.
ADO. net Community version is the previous blog "ADO. net theory + practice is a version of the previous blog, which is too formal and does not combine its summary with itself, so it is improved.