What Is ADO.NET?

ADO.NET is a strategic API from Microsoft for data access in the modern era of distributed, Internet-based applications. ADO.NET contains a set of interfaces and classes that enable you to work with data from a wide range of databases, including Microsoft SQL Server, Oracle, Sybase, Access, and so on.

ADO.NET Data Providers

ADO.NET uses the concept of a data provider to provide efficient access to different types of databases. Each data provider includes classes to connect to a particular type of database. The .NET Framework includes three data providers, as shown in the following table.

Data Provider


.NET Framework Data
Provider for SQL Server

Contains classes that give optimized access to SQL Server 7 and later

.NET Framework Data
Provider for OLE DB

Contains classes that give access to SQL Server 6.5 and earlier; also provides access to databases such as Oracle, Sybase, Access, and so on.

.NET Framework Data
Provider for Oracle

Contains classes that give access to Oracle databases

ADO.NET Namespaces

The classes in ADO.NET are divided into the six namespaces shown in the following table.




This is the core namespace in ADO.NET, and it contains generic classes that are used for any type of data source. For example, the DataSet class is defined in this namespace.


Defines common interfaces that are implemented appropriately by each data provider.


Defines classes for the SQL Server data provider. These classes include SqlConnection, SqlCommand, SqlParameter, SqlDataReader, SqlTransaction, and SqlDataAdapter. (A data adapter is a special object that enables you to load and save data in a DataSet; you will learn more about data adapters later in this chapter.)


Defines classes for the OLE DB data provider. These classes include OleDbConnection, OleDbCommand, OleDbParameter, OleDbDataReader, OleDbTransaction, and OleDbDataAdapter.


Defines classes for the Oracle data provider.


Defines classes for working directly with ODBC.


Defines classes that represent native SQL Server data types.


Defines XML-related classes. ADO.NET is tightly integrated with XML. For example, there is a class named XmlDataDocument in the System::Xml namespace that enables you to treat relational data as if it were an XML document. See XmlDataDocument in Microsoft Visual Studio .NET Help for details.

ADO.NET Assemblies

The majority of ADO.NET classes are in the System::Data assembly (one notable exception is the XmlDataDocument class, which is in the System::Xml assembly). To use these assemblies, you will need to include the following statements in your application:

#using <System.Data.dll> // This assembly contains ADO.NET classes #using <System.Xml.dll> // This assembly contains XML classes, // such as XmlDataDocument 

Note that if you are creating projects using Visual Studio .NET, the reference to System.Data.dll will be provided for you. Once you have imported these assemblies, you can import the required namespaces for your application. For example, if you need to access a SQL Server 2000 database, you need the following using statement:

using System::Data::SqlClient;

Microsoft Visual C++  .NET(c) Step by Step
Microsoft Visual C++ .NET(c) Step by Step
ISBN: 735615675
Year: 2003
Pages: 208

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