Creating more than one Connection with DAAB

Topics: Building and extending application blocks, Data Access Application Block, Enterprise Library Core, General discussion
May 23, 2009 at 7:01 PM


I am trying to use configuration file for creating SQL Server connections using Data Access Application Block (DAAB). However, I am always getting the default database connection. Is there any way, I can get the required database connection?



May 25, 2009 at 4:32 AM
Edited May 25, 2009 at 4:32 AM


Yes, you will get the default database if you do it like this:

Database db = DatabaseFactory.CreateDatabase();

The CreateDatabase() method w/o parameter will always get the specified default database. In order to get a specific database, you can use the CreateDatabase(string name) method which takes the name of the connection string.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.