This article describes the features, architecture and benefits of ADO.NET.
Microsoft provided a set of programable objects known as the ActiveX Data Object(ADO) that allow access to OLEDB. ADO defines an object model that uses a set of object processing methods and properties. The methods perform some operations necessary to gain access to and update a data source. The properties either represents some attributes of data or control the behaviour of some object method associated.
Microsoft has released ADO.NET as the data access technology while working in the .NET platform. ADO.NET is the primary library for building solutions within the .NET framework while COM based applications will still be using ADO or OLEDB as data access tool.
ADO.NET deals with accessing and manipulating databases. It comprises of many namespaces and classes to manipulate data. ADO.NET provides access to data sources such as MS SQL Server, OLEDB, XML. Applications written in .NET compliant languages connect to these data sources to access, manipulate and update data.
This technology takes its name from ADO(ActiveX Data Object). ADO combines the best features of DAO(Data Access Object) and RDO(Remote Data Object).
ADO relied on a connection based model. In the connected approach, the client had to be connected with the server and remain connected till the whole procedure or transaction was completed. Time resources and bandwidth became major constraints on such architecture.
To solve this problem the latter version of ADO used RecordSet. All the contents from the data source were copied into RecordSet. This allows clients to get disconnected from the server, work on the RecordSet and copy the changes back to the data source again. This approach did not succeed much because it requires COM marshalling to transmit disconnected data, it support only those datatypes that were defined by the COM standards and hence required type conversion.
ADO.NET can be used to access data sources using new .NET data providers as well as existing OLEDB data providers using the OLEDB.NET data provider.
FEATURES OF ADO.NET
If the connection to a database is kept open till the application is running, it will take up more time. In such cases databases can maintain only a small number of concurrent connections. The overhead of maintaining these connections decreases the overall application performance.
Applications which are on the web has to be easily scalable, since traffic to a website can go up by any order of magnitude in a very short period.
- DATA IS CACHED IN DATASETS
The most common task with database is to retrieve data and do some kind of processing with it. In most of the real life situations application require data from multiple tables. A DataSet is a cache of records retrieved from the databases. It works like a virtual data store-it includes one or more tables based on the tables in the actual database and it can include information about the relationship between those tables and constraints on what data the table can contain.
DataSet is independent of the following,
DATA SOURCE: Once the data is in a DataSet you can work with it using a consistent object model, regardless of its original source.
DATA IS PERSISTED AS XML: In ADO.NET data is transfered from the data-store to the XML document.
ADO.NET is a collection of classes, interfaces, structures and enumulated types that manages data access from relational data sources with in the .NET framework. These collections are organised into namespaces such as System.Data, System.Data.OLEDB and System.Data.SqlClient.
The ADO.NET components have been designed to separate data access from data manipulation. To accomplish the ADO.NET provides two central components, the DataSet and the .NET DataProvider.
The .NET DataProvider is a set of components that includes the Connection, Command, DataReader and DataAdapter objects. It is used for connecting to a database , executing commands and retrieving results. Using the .NET data provider we can either access database directly or use the disconnected approach. For the disconnected approach we use DataSet class.
Connection Object: It is used to connect to the data source. Data source can be any database file. The connection object contains information like the provider name, server name, datasource name, user name and password.
Command Object: It is used for connect the connection object to a DataReader or DataAdapter object. The command object allow us to execute SQL statement or a stored procedure in a data source.
DataReader Object: It is used to read the data in a fast and efficient manner from the database. It is generally used to extract one or a few records or specific field values or to execute simple SQL statement.
DataAdapter Object: It is used to fill data from the database into the DataSet object. it is use din the disconnected approach.
BENEFITS OF ADO.NET
- Scalability: ADO.NET works on DataSet that can represent a whole database or even a data table as a disconnected object and thereby eliminates the problem of the constraints of number of databases being connected. In this way scalability is achieved.
- Data Source Independence: In ADO.NET DataSet is completely independent of data source and no way DataSet is controlled by the data source as it happens in case of RecordSet.
- Interoperability: As ADO.NET transmits the data using the format of XML which is not dependent on ADO.NET or windows platform.
- Strongly Typed Fields: It supports strongly typed fields by using CTS.
- Performance: The performance in ADO.NET is higher in comparison to ADO that uses COM marshalling.
- Firewall: As in ADO.NET transmission is via XML format, therefore it can pass through firewalls.