Using Microsoft® Enterprise Library Application Blocks can simplify application development by wrapping common tasks, such as data access, into portable code that makes it easier to move your application from one DBMS to another. The classes in the Data Access Application Blocks (DAABs) provide access to the most frequently used features of ADO.NET. Applications can use the DAABs for tasks such as passing data through application layers and return changed data back to the database. Using DAABs eliminates the need to keep writing the same data access tasks for each new or revised application, so you can spend your time in more productively.
The DataDirect Connect® for ADO.NET Data Providers can be used with Data Access Application Blocks. This article describes how to use the Data Access Application Blocks in your applications.
The article consists of the following sections:
![]()
Data Access Application Blocks (DAABs) are designed to allow developers to replace ADO.NET boiler-plate code with standardized code for everyday database tasks. The overloaded methods in Database class can:
If your application needs to address specific DBMS functionality, you can use the DataDirect Connect for ADO.NET data provider.
DAABs include 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 DAAB is used with ADO.NET, increasing efficiency and productivity when creating applications for ADO.NET. The abstract Database class provides a number of methods, such as ExecuteNonQuery, ExecuteReader, and ExecuteScalar, that are the same as the methods used by the DbCommand class, or, if you are using database-specific code, a data provider-specific class such as OracleCommand.
Although using the default DAAB during development is convenient, the resulting application lacks portability. When you use the provider-specific DataDirect Connect for ADO.NET DAAB implementation, the application includes the DataDirect data provider’s SQL leveling capabilities. You have more flexibility, whether your application needs to access multiple databases, or whether you anticipate a change in your target data source.
The application block supplements the code in ADO.NET that allows you to use the same code with different database types. You have two choices when using a DAAB with DataDirect Connect for ADO.NET:
The GenericDatabase class option is less suited to applications that need specific control of database behaviors. For portability, the provider-specific solution is the optimal approach.
If your application needs to retrieve data in a specialized way, or if your code needs customization to take advantage of features specific to a DBMS, using the DataDirect Connect for ADO.NET data provider for that DBMS might be better suited to your needs.
![]()
Before you can configure the DAAB for use with your application, you must set up the environment:
Configuring the Data Access Application Block consists of two parts:
Now, use the Enterprise Library Configuration Tool to add a new DAAB entry:


To add the DAAB to a new or existing application, perform these steps:
using Microsoft.Practices.EnterpriseLibrary.Data; using System.Data;

![]()
Now that you have configured the DAAB, you can build applications on top of this DAAB.
In the following example, we use the DAAB MyOracle and the DatabaseFactory to generate an instance of a Database object backed by an Oracle data source.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
namespace DAAB_Test_App_1
{
class Program
{
static void Main(string[] args)
{
Database database = DatabaseFactory.CreateDatabase("MyOracle");
DataSet ds = database.ExecuteDataSet(CommandType.TableDirect, "SQLCOMMANDTEST_NC_2003SERVER_1");
}
}
}
The Microsoft Enterprise Library DAAB coding patterns are now at your disposal.
![]()
The following articles provide additional information about using Application Blocks:
![]()
When you use the Microsoft® Enterprise Library Data Access Application Blocks for standard data access tasks, the intricacies of the underlying databases are abstracted away from the application.
DataDirect Connect for ADO.NET fills in the gaps in functionality that the Enterprise Library DAAB, by design, leaves open. With the DataDirect data providers, you can build a true heterogeneous data access layer with the SQL leveling capabilities that DataDirect is known for.