Overview of ADO.NET Namespaces and Classes

The System.Data namespace and its five supporting namespaces define the ADO.NET functionality. In this section, we briefly describe these namespaces. Later chapter describe these namespaces and classes in more detail. These namespaces reside in the System.Data.dll assembly.


In the .NET Framework, each class belongs to a namespace. A namespace is a logical group of related types and their definitions. To access a type defined in a namespace, you must reference the namespace by using the Imports keyword or by referencing it directly. For example, the System namespace defines all the system-related functionality. For example, the Console class of the System namespace represents the system console. If you want to access the Console class, you need to call System.Console or Imports System in your application.

The six general ADO.NET namespaces are System.Data, System.Data.Common, System.Data.OleDb, System.Data.Odbc, System.Data.SqlClient, and System.Data.SqlTypes. Besides these namespaces, each new data provider may have its own namespace. For example, if you install the Oracle .NET data provider, the installation adds a new namespace, the Microsoft.Data.OracleClient namespace, which also belongs to ADO.NET.

The System.Data namespace is the core namespace of ADO.NET. It consists of the base classes for the ADO.NET architecture. All data providers use these classes. It defines classes that represent tables, columns, rows, and DataSets. Some common classes from this namespace are DataView, DataViewManager, DataSet, DataTable, DataRow, DataColumn, and DataRelation. To use these classes in your applications, you need to add a reference to the System.Data namespace.


All classes in the .NET Base Class Library are derived from the Object class and represent a type. Some authors and documentation also use the word type for a .NET Framework class.

The System.Data.Common namespace defines common classes. These classes are base classes for concrete data provider classes. All data providers share these classes. DBConnection, DataAdapter, DbDataAdaper, DataColumnMapping, and DataTableMapping are some of the classes defined in this namespace. To use these classes in your application, you need to add a reference to the System.Data.Common namespace in your application. Sql, OleDb, and Odbc.

The System.Data.OleDb namespace defines classes to work with OLE-DB data sources using .NET OleDb data providers. To work with an OLE-DB data source, you must have an OleDb provider for that data source. Each data provider component has a class corresponding to it. These classes start with OleDb, followed by the component. For example, the OleDbConnection class represents a Connection object. Some of the common classes of this namespace are OleDbDataAdapter, OleDbDataReader, OleDbCommand, OleDbCommandBuilder, OleDbError, OleDbParameter, OleDbPermission, and OleDbTransaction. To use these classes in your application, you need to add a reference to the System.Data.OleDb namespace in your application.

Similar to the System.Data.OleDb namespace, the System.Data.Odbc namespaces define Odbc .NET data provider classes to work with the ODBC data sources. To work with ODBC data sources, you need to install an ODBC driver for a database. The System.Data.Odbc namespace classes start with Odbc, followed by the component. For example, the OdbcConnection class represents a Connection object. Some of the common classes of this namespace are OdbcDataAdapter, OdbcDataReader, OdbcCommand, OdbcCommandBuilder, OdbcError, OdbcParameter, OdbcPermission, and OdbcTransaction. To use these classes in your application, you need to add a reference to the System.Data.Odbc namespace in your application.

The System.Data.SqlClient namespaces define Sql .NET data provider classes to work with SQL Server 7.0 or later databases. Similar to Odbc and OleDb classes, the classes in this namespace start with Sql, followed by the component. For example, common classes are SqlConnection, SqlDataAdapter, SqlCommand, SqlDataReader, and SqlTransaction.

The last namespace, System.Data.SqlTypes, provides a group of classes representing the specific types found in SQL Server. Some of these classes are SqlBinary, SqlMoney, SqlString, SqlInt32, SqlDouble, SqlDateTime, and SqlNumeric.

We discuss these namespaces, classes, and their members in more detail in Chapters 3 and 4.

Applied ADO. NET(c) Building Data-Driven Solutions
Applied ADO.NET: Building Data-Driven Solutions
ISBN: 1590590732
EAN: 2147483647
Year: 2006
Pages: 214

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