ADO.NET( ActiveX Data Objects) is the new database technology used in Dot Net platforms. ADO.Net is the next step in the evolution of Microsoft ActiveX Data Object(ADO).
It does not share the same programming model but shares much of the ADO functionality. ADO.NET is a marketing term that covers the classes that expose the data access service of the dot Net framework.
ADO.Net is a natural evolution of ADO and is build around N-tier application development. It has been created with XML as its core.
Data Storage is a method of storing specific items that together constitute a unit of information. Individual data items on themselves are of little use; they become valuable resources only when put into context with other data items.
The following describes different methods of data storage.
1. Unstructured Data
In this method, data has no logical order to store.
Take simple memos for example.
2. Structured (Non-Hierarchical)
In this method, data is separated into units, but the units are organized strictly by their order.
Examples of structured data are comma-separated value (CSV) files or tab-separated files, Microsoft Excel spreadsheet, Microsoft exchange files, Microsoft active directory files, indexed sequential access method files.
In this method, the data is organized in a tree-structured, with nodes that contain other nodes.
For example, XML data documents are hierarchical data.
4. Relational Database
In this form, the data is organized in tables, with columns containing a specific type of data and rows containing a single record. Tables can be related over columns with identical data.
For example, Microsoft SQL Server and Microsoft Access Database, Oracle database are relational databases.
5. Object-Oriented Database:
In this method, data is organized as objects.
For example, objectivity/DB is an object-oriented database.
ADO.NET can support all of the data formats described above.
Connected vs Disconnected Mode
For much of the history of computers, there was only a connected environment available. With the advent of the internet, disconnected work scenarios have become commonplace, and with the increasing use of handheld devices, disconnected scenarios are becoming nearly universal.
Laptops, notebooks, and other portable computers allow you to use applications when you are disconnected from servers of the database.
In many situations, people do not work entirely in a connected or disconnected environment, but rather in an environment that combines the two approaches.
Connected ADO.NET Environment
A connected environment is one in which a user or an application is constantly connected to a data source.
A connected scenario offers the following advantages:
- A secure environment that is easier to maintain,
- Concurrency that is easier to control,
- Data is more likely to be current than in other scenarios.
A connected scenario has the following disadvantages:
- It must have a constant connection,
Disconnected ADO.NET Environment
The Second Type of environment of ADO.NET is a disconnected environment. A disconnected Environment is one in which a user or an application is not constantly connected to a source of data.
Various mobile users who basically work with laptop computers are the primary users in a disconnected environment. Users can take a subset of data with them on a disconnected computer, and then merge changes back into the central data source.
A Disconnected environment provides the following advantages:
- You can work at any time that is convenient for you;
- You can connect to a data source at any time to process a request;
- Other users can use the connection;
- A disconnected environment improves the scalability and performance of applications.
A disconnected environment has the following disadvantage.
- The data is not always up to date,
- Change conflicts can occur and you must resolve them.
Advantages of ADO.NET
ADO.net provides the following advantage over the data access models and components.
ADO.Net basically uses XML as the format for transmitting data from a data source to a local in-memory copy of the data.
When an increasing number of users work with an application, the increased use can strain resources by using the N-tier application logic across additional tiers.
The ADO.NET architecture basically uses local in-memory caches to hold copies of data, making it easy for additional tiers to trade information.
The ADO.NET programming model uses strongly typed data. Strongly typed data makes the code more concise and easier to write because Microsoft Visual Studio .NET provides statement completion.
ADO.NET helps you provide costly data type conversations because of its use of a strong type of data.
The ADO.NET programming model encourages programmers to conserve system resources for applications that run over the web because data is held locally in in-memory caches.
There is no need to retain data sources or maintain an active database connection for extended periods.
ADO.NET Data Providers
- SqlClient (System.Data.SqlClient)
- OleDb (System.Data.OleDb)
- Odbc (System.Data.Odbc)
- OracleClient (System.Data.OracleClient)
ADO.NET Entity Framework
- LINQ to Entities
- Typed ObjectQuery
- EntityClient (System.Data.EntityClient)
- LINQ to SQL
ADO.NET has various components. Basically, DATASET is the main component of disconnected architecture. The DATASET class is the central component of the disconnected architecture.
- A DATASET can be populated from either a database or an XML stream.
- In DATASET the original source of the data is basically immaterial From the perspective of the user of the dataset.
- A consistent programming model basically uses for all application interaction with the DATASET.
- ADO.Net basically provides a different type of arch The second Key Component of Ado.net architecture is the .NET Data Provider, which provides access to the database, and we can use it to populate a DATASET.
We can also use a data provider directly by an application to support a connected mode of database access.
ADO.NET Architecture (CONNECTED)
.NET Data Provider
The most important part of ADO.NET is the DATA provider. A DOT NET data provider is basically used for connecting to a database.
- The DOT NET DATA provider basically provides classes. We can use these classes to execute commands and to retrieve results.
- Basically, these Results are either used directly by the application or else they are placed in a Dataset. else they are placed in a Dataset.
A .NET data provider implements four key interfaces:
- IDbConnection: The major use of DATA provider is to establish a connection to a specific or particular data source.
- IDbCommand: IDbCommand DATA Provider use to Execute a command at a data source.
- IDataReader: IDataReader basically provides an efficient way to read a stream of data from a data source. the data access provided by a data reader is forward-only and read-only.
- IDbDataAdapter is basically using to populate a Dataset from a data source.
The architecture of ADO.NET focuses on the specification of these interfaces and we can create different implementations to facilitate working with different data sources.
Another task of a .NET data provider is analogous to an OLE DB provider. The OLE DB provider implements COM (Component Object Model) interfaces, and a .NET data provider implements .NET interfaces.
Namespaces for ADO.NET classes include the following
- System.Data consist of classes that constitute most of the ADO.NET architecture.
- System.Data.OleDB contains classes that basically provide database access using the SQL Server data provider.
- System.Data.SqlClient contains classes that provide database access using the OLE DB data provider.
- System.Data.SqlTypes contains classes that represent data types used by SQL server.
- System.Data.Common contains classes that data providers share.
- System.Data.EntityClient contains classes supporting the ADO.NET Entity Framework.
With that, we wrap up the overview of ADO.NET.
ADO.NET can be used in your Microsoft Visual C# applications with the help of a different type of mode. The .NET Framework basically includes the DataSet object to work directly with data. The object gives you the flexibility and control to represent the data in any way needed.
In ADO.NET, it is very easy to identify that the object can bound easily to controls in either Windows Forms or Web Forms to tie the controls and datasets together. This allows you to build data entry screens quickly.
Basically, the .NET Framework also contains two types of data providers that are basically used to access data sources. One is the OLE DB .NET Data Provider and the second is the SQL Server .NET Data Provider.
Using the Connection, Command, DataReader, and DataAdapter objects included in each data provider, you can get complete access to your data.