Scenarios and Goals

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

The Data Access Application Block is designed to address the most common tasks developers face when they are writing database applications. These tasks are arranged according to scenarios. Each scenario gives an example of a real-world situation, such as retrieving information from a catalog or performing a banking transaction, describes the database functions the situation requires, and shows the code that accomplishes the task.

The goal of arranging these tasks according to scenarios is to give the code some context. Instead of showing an isolated group of methods, with no sense of where they can best be used, scenarios provide a setting for the code, placing it in situations familiar to many developers whose applications must access databases.

The scenarios are the following:

  • Using a DataReader to retrieve multiple rows of data
  • Using a DataSet to retrieve multiple rows of data
  • Executing a command and retrieving the output parameters
  • Executing a command and retrieving a single-value item
  • Performing multiple operations within a transaction
  • Retrieving XML data from a SQL Server
  • Updating a database with data contained in a DataSet object

When to Use the Data Access Application Block

The Data Access Application Block includes a small number of methods that simplify the most common methods of accessing a database. Each method encapsulates the logic required to retrieve the data and manage the connection to the database. You should consider using the application block if your application uses standard data access techniques.

The application block supplements the code in ADO.NET 2.0 that allows you to use the same code with different database types. It includes classes for SQL Server and Oracle databases. These classes contain code that provides database-specific implementations for features such as parameter handling and cursors. In addition, the GenericDatabase class allows you to use the application block with any configured ADO.NET 2.0 DbProviderFactory object. You can extend the application block by adding new database types that include database-specific features or that provide a custom implementation of an existing database. The only requirement is that an ADO.NET 2.0 DbProviderFactory class exists for the target database.

When to Use ADO.NET Directly

The Data Access Application Block is a complement to ADO.NET; it is not a replacement. The application block provides simplicity and convenience while helping developers use ADO.NET with best practices. If your application needs to retrieve data in specialized way, or if your code needs customization to take advantage of features specific to a particular database, using ADO.NET might better suit you.

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.
Show: