2.2. Design

The data access layer performs CRUD operations against the database. CRUD stands for create, read, update, and delete. The object model that the .NET Framework provides for performing these operations is ADO.NET. Several .NET data provider namespaces contain implementations of the ADO.NET object model; the most common are System.Data.SqlClient, System.Data.OracleClient, System.Data.OleDb, and System.Data.Odbc. Each namespace has Connection, Command, DataReader, DataAdapter, Parameter, and Transaction objects. The name of the object is prefixed by Sql, Oracle, OleDb, or Odbc, respectively. For example, the SqlClient Connection object is called SqlConnection. Each object implements an interface that is defined by ADO.NET.

For example, all the connection objects implement the IDBConnection interface, which has a standard set of methods for opening, closing, and executing commands against a database. This provides consistency across all data providers and makes it easier to switch between providers. If you had an application that needed to support both SQL Server and Oracle, you could implement your classes with generics and specify the name of the class you want to create when creating the object. This would ensure that the open method for each performs the same action, as they implement the same interface.

2.2.1. ADO.NET Connections

Before passing data to or from the database, you must first connect to the database. This is accomplished by using a Connection object ...

Get ASP.NET 3.5 Enterprise Application Development with Visual Studio® 2008: Problem - Design - Solution now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.