How do you use DAAB?

Topics: Data Access Application Block
Jun 27, 2010 at 6:46 PM

I am trying to use the enterprise library for Data access but it is not working. I downloaded the libraries and added a reference to Microsoft.Practices.EnterpriseLibrary.Data.dll and also added the following statements.

using Microsoft.Practices.EnterpriseLibrary.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;

But when I try to create a Database object I get the following error.

Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Database();


Cannot create an instance of the abstract class or interface Microsoft.Practices.EnterpriseLibrary.Data.Database

Jun 28, 2010 at 12:34 AM

Did you set the Default Database property of the data configuration block? 


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.

Jun 28, 2010 at 3:16 AM

I was missing the whole configuration block. I added a configuration block and default database, and now this code works

Database db = DatabaseFactory.CreateDatabase();

Thank you!!