Chapter 4: Migrating from ADO to ADO.NET


.NET Framework provides a new data access component, ActiveX Data Objects (ADO). NET, which includes classes and data providers that allow .NET applications to access databases efficiently. You can migrate applications developed using ADO to ADO.NET for improved data access.

This chapter describes the advantages of migrating from ADO to ADO.NET. It also explains how to migrate applications using ADO to ADO.NET.

Advantages of Migrating from ADO to ADO.NET

ADO.NET provides many advantages over ADO in different areas, such as access to multiple data sources, performance, scalability, interoperability, and maintainability.

Access to Multiple Data Sources

The ADO.NET dataset allows you to fetch data from multiple data sources. A dataset object can contain data from a SQL Server database and an Oracle database, whereas ADO recordsets can contain data from only one data source.

In addition, a dataset object can store data from multiple tables or data sources. ADO recordsets can work with only one table at a time and you need to create a JOIN query to retrieve data from multiple tables into a result table.

Performance Enhancements

ADO.NET provides disconnected datasets that allow the database server to perform efficiently even if the number of connection requests increases. A DataSet object is an in-memory cache of data that does not require a dedicated connection, unlike ADO recordsets. For example, in an online shopping application that uses ADO to access a database, customers add their products to a shopping cart. During the time spent in purchasing the products, the connection to the database remains open. If a large number of end users visit the Web site simultaneously, there will be a heavy load on the Web server and the database server of the Web site may stop responding. You can avoid this situation using ADO.NET because it employs a disconnected model. As a result, while selecting products, the connection to the database is closed. You need to open the connection only to place an order for the selected products.

When you use disconnected ADO recordsets among different tiers of your application, you incur a high processing cost by converting the values in the recordset to the data types that Component Object Model (COM) recognizes. ADO.NET does not require this data type conversion, which decreases processing costs and improves performance.

Scalability

ADO.NET improves scalability because it employs disconnected data access and does not retain database locks or active database connections for long periods. As a result, an application can handle a large number of end users; whereas ADO recordsets are connection-oriented, which means that they require an established connection while the application uses the recordsets.

Interoperability

ADO.NET uses eXtended Markupo Language (XML) to transmit datasets across the network. As a result, any component that can read the XML format can process the data in the transmitted datasets; it need not necessarily be an ADO.NET component. For example, an Information Retrieval .NET Web service provides methods that return information about services at a particular location in the form of a dataset object. You can call the methods of this Web service from a Java application. When you perform the same function using ADO recordsets, the COM library should be at both the source and the destination computer. ADO assumes that the components used for communication use the same protocol and data format.

In addition, ADO.NET enables communication across firewalls, because the native format of dataset is XML. XML is the only structured text that can pass through firewalls.

Maintainability

Maintaining applications is easier in ADO.NET as compared to ADO. For example, as a Web site becomes popular, the number of visitors accessing the Web site increases. This leads to an increased load on the Web server. You can separate the business tier and the presentation tier on two separate computers that run on different platforms to reduce the load on one computer. As a result, the number of tiers in the application increases and it is necessary to share information between the two tiers in a heterogeneous environment because both computers run on different platforms.

You cannot pass ADO recordsets in a heterogeneous environment but can use the XML datasets that ADO.NET provides to share information across heterogeneous platforms. This is because the native format of datasets is XML. This allows you to efficiently maintain the Web site.




Migrating Unmanaged Applications to. NET
Migrating Unmanaged Applications to. NET
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 31

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net