ADO and ADO. net

Source: Internet
Author: User

(Excerpted from ASP. NET 3.5)

I. Ado and ADO. net

Compared with ADO, ADO. NET has made great improvements. Use ADO. net, which makes it easier to develop databases. Some of them are changes made to developers, including ease of use and applicability. The second change makes ADO. compared with ADO, net is more flexible, powerful, and easy to upgrade and use.

Ii. Ado Overview
Microsoft's ActiveX Data Objects (ADO) is a COM component used to access data sources. It provides Programming Language And a unified data access mode. Allows developers to write and access data Code Instead of worrying about how the database is implemented, we only need to care about the database connection. When accessing a database, the knowledge about SQL is not necessary, but the SQL commands supported by a specific database can still be executed through the command objects in ADO.
During the development process, ADO provides the com application for oledb data Program Database Operations are encapsulated. Ado supports various developers' needs. At the same time, ADO can also build client record sets like ADO. net, use loosely coupled record sets, and process oledb data shaping sets.
Compared with ADO. net, ADO also supports some special methods, such as the server-side cursable movenext. However, to use server cursors, you must use and save database resources. Therefore, when a large number of cursors are used on the server, it may have a significant negative impact on the performance and scalability of the application. To use ADO, you also need to configure the firewall to enable the sending of COM requests for data interaction, which may cause certain security problems. The ADO programming model is as follows:
1. Connect to the data source (connection). You can choose to start the transaction.
2. You can choose to create an object (command) that represents an SQL command ).
3. You can specify columns, tables, and values in SQL commands as variable parameters ).
4. execute commands (command, connection, or recordset ).
5. If the command is returned as a line, the row is stored in the stored object (recordset ).
6. You can choose to create a storage object view for sorting, filtering, and locating data (recordset ).
7. edit data. You can add, delete, or modify rows and columns (recordset ).
8. When appropriate, you can use the changes in the storage object to update the data source (recordset ).
9. After using the transaction, you can accept or reject the changes made in the transaction. End the transaction (connection ).
From the above programming model, we can see that ADO. net is similar to ADO in many aspects, but ADO. net is not from ADO. net version, ADO and ADO. net is two different data access methods.

Iii. Ado. NET and ADO
The name of ADO. Net originated from ADO (ActiveX Data Objects). ADO is used to access data in Microsoft technology. Therefore, Microsoft wants to use the ADO. Net name to indicate to developers that this is a preferred data access interface in the. NET programming environment and Windows environment.
ADO. NET provides platform interoperability and Scalable Data Access. Ado. Net enhances non-connection programming mode support and supports rich XML. Since the transmitted data is in XML format, any application that can read the XML format can process data. In fact, components that accept data are not necessarily ADO. NET components. They can be a Microsoft Visual Studio-based solution or any application running on other platforms.
It can be said that the traditional ADO and ADO. NET are two different data access methods, both in the memory to save data, or open and close the database operation modes are different.
1. Data in memory
When ADO. NET is used, data is stored in the memory and stored in the memory in the form of dataset datasets, while ADO is stored in the memory in the form of a recordset record set.
During ASP development, after connecting to the database, the data set for query operations is usually stored in the record set and traversed using movenext and other methods, you can also use other methods to query and extract any row. In ASP. net, ADO. the datarelation object provided by net maintains information about the master record and detailed data record, and provides methods for users to obtain records related to the records being operated.
2. Data Representation
In ADO, a record set is represented as a table. To include data from tables in multiple databases, you must use join queries in complex SQL statements to combine the data of tables in each database into a single record set.
In ADO. Net, a dataset itself is a set of one or more tables. Compared with a record set, a dataset can store multiple independent tables and maintain information about the relationship between tables. Therefore, ADO. Net can maintain and store tables with complex data structures and imitate the database structure, such as table self-Association and one-to-many or many-to-many Relational Tables.
3. Data Connection and disconnection
ADO is designed for connection access. In contrast, ADO. Net only allows database operations to open connections. A dataset can read rows, disconnect the database, and modify records in the dataset. When you need to update the resources in the dataset to the database, ADO. NET is connected to the database and updated.
4. Data Sharing
In ADO, if you need to enable the function of disconnecting data from the data connection in ADO. net, you must transmit data between COM components, which causes security problems. In anti-virus software, some anti-virus software may disable communication between COM components by default, which makes maintenance difficult for developers. However, ADO. Net can use dataset to transmit data without the firewall restrictions, because the data assembly transmitted by dataset is converted into an XML stream for transmission. Compared with ADO data sharing, ADO. NET has the following advantages:
Break through the restrictions of the COM data type: Since ADO. Net transfers data based on XML streams, there is no limit on the data type.
Reduce data type conversion: Compared with ADO, ADO. Net reduces the conversion of a large number of data types and improves performance.
Can penetrate the firewall: the XML-based method for transmitting data can easily penetrate the firewall.
5. Architecture Design
In architecture design, ADO. NET and ADO are also different. Compared with ADO, ADO. NET is more convenient and concise. From the design perspective, ADO. NET is more perfect.
In ADO, adorecordset objects are used to connect and operate data. An adorecordset object is a large object that provides various types of cursor capabilities, for example, a quick and real-time cursor to a connectionless client cursor. However, using the adorecordset object makes it difficult to customize the data operation methods. In ADO. net, ADO. Net splits the adorecordset object method in ADO, divides several functions into multiple classes, and calls them between classes. This makes it easier for developers to customize data connections and operations.
Note: In applications, ADO and ADO. Net can coexist, because in. net, the com interoperability service can also be used to use ADO.

Iv. Common ADO. Net objects
ADO. NET provides some common objects for developers to perform database operations. These commonly used objects are usually used in application development. For intermediate developers, master these commonly used ADO.. Net object, which can encapsulate database operation classes to simplify development. Common ADO. Net objects include:
1. connection object.
2. dataadapter object.
3. Command object.
4. DataSet object.
5. datareader object.
The above objects are very important in the. NET application to operate data. They not only provide convenience for data operations, but also provide advanced functions for developers. Solve specific needs for developers.

 

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.