Overview of ADO.NET Namespaces and Classes


Overview of ADO.NET Namespaces and Classes

System.Data and its five supporting namespaces define the ADO.NET functionality. In this article, you'll take a brief look of these namespace. These namespaces reside in the System.Data.dll assembly. Figure shows the contents of this assembly in the IL DASM utility. 

 pic.gif

Figure: The system. Data assembly contents in the IL DASM utility

The six ADO.NET namespaces are the System.Data, System.Data.Common, System.Data.Oledb, Microsoft.Data.Odbc, System.Data.SqlClient, and System.Data.SqlTypes.

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 table, columns, row, and datasets some common classes from this namespace 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.

NOTE: All classes in the .NET base library are derived from the Object class and represent a type. Some authors and documentation also use 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. These classes are shared among all data providers. DBConnection, DataAdapter, DBDataAdapter, DataColumnMapping and DataTableMapping are some of the classed 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.

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 OLE-DB 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, 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, your need to add a reference to the System.Data.OleDb namespace in your application.

Similar to the System.Data.OleDb namespace, the Microsoft.Data.Odbc namespaces define ODBC.NET data provider classes to work with the ODBC data sources. To work with ODBC data source, you need to install an ODBC driver for a database. The Microsoft.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 Microsoft.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. For example, common classes are SqlConnection, SqlDataAdapter, SqlCommand, SqlDataReader, and SqlTransaction.

The last namespace, System.DataSqlTypes, providers a group classes representing the specific types found in SQL server. Some of these classes are SqlBinary SqlMoney, SqlString, SqlDouble, SqlDateTime, and SqlNumeric.