Managed C++ and .NET Development: Visual Studio .NET 2003 Edition

Databases are made up of tables, views, relationships, constraints, and stored procedures. They're usually the domain of the database architects, designers, developers, and administrators. ADO.NET, on the other hand, is how application developers get their hands on these (meaning the tables, views, and so forth—not the architects and designers, though sometimes I'd like to get my hands on the designers....) With ADO.NET, it's possible to keep these two diverse software developing worlds separate, letting the specialists in both fields focus on what they do best.

ADO.NET is a set of classes that encompasses all aspects of accessing data sources within the .NET architecture. It's designed to provide full support for either connected or disconnected data access, while using an Extensible Markup Language (XML) format for transmitting data when data transfer is required. Chapter 13 contains more details about XML, so don't worry about it for now. Just think of ADO.NET as a programmer's window into a data source, in this case the DVC_DB database.

The classes that make up ADO.NET are located primarily in two assemblies: System.Data.dll and System.Xml.dll. To reference these two assemblies, you need to add the following two lines to the top of your application source:

#using <System.Data.dll> #using <System.Xml.dll>

The addition of the System.Xml.dll assembly is due to the heavy reliance on XML in the internals of ADO.NET and in particular the class XmlDataDocument.

Seven namespaces house all of ADO.NET's functionality. These namespaces are described at a high level in Table 12-1.

Table 12-1: ADO.NET Namespaces

NAMESPACE

DESCRIPTION

System::Data

Contains most of the classes that make up ADO.NET. The classes found within this namespace are designed to work independently of the type of data source used. The most important class in this namespace is the DataSet class, which is the cornerstone of disconnected data source access.

System::Data::Common

Contains the common interfaces used by each of the managed providers.

System::Data::Odbc

Contains the classes that make up the ODBC managed provider, which allows access to ODBC-connected databases such as MySQL. The classes contained within this namespace are all prefixed with Odbc.

System::Data::OleDb

Contains the classes that make up the OLE DB managed provider, which allows access to databases such as Sybase, Microsoft Access, and Microsoft SQL Server 6.5. The classes contained within this namespace are all prefixed with OleDb.

System::Data::Oracle

Contains the classes that make up the Oracle managed provider, which allows access to Oracle8i and later databases. The classes contained within this namespace are all prefixed with Oracle.

System::Data::SqlClient

Contains the classes that make up the SQL Server managed provider, which allows access to Microsoft SQL Server 7.0 and later databases. The classes contained within this namespace are all prefixed with Sql.

System::Data::SqlTypes

Contains classes for native data types associated with SQL Server.

Now that you have a basic understanding of what ADO.NET is, let's take a small sidetrack from Managed C++ and see how to build a database using Visual Studio .NET.

Категории