I am new to using EntLib 4.1 - using to 2.0. In the building of our new application, it has been determined that there will be a number of different databases in use. In the base class that I am writing, I want to insure that the database name that is being
passed in is a valid one. Is there a way to accomplish this from within the DAAB? Or should I build in a different means of determining the database names, i.e. perhaps an enum?
Apr 13, 2009 at 12:21 PM
Edited Apr 13, 2009 at 12:21 PM
To what extent you want to know that your database instance name is valid? Is it to the point that you ensure that it exists? AFAIK, there is no direct way from DAAB to enumerate all the database instance from the config. But you can try it this way.
foreach (ConnectionStringSettings item
this will enumerate all the database instance from the config file. Also, if you want to test if the database exist, try opening a connection against a database instance:
Database db =
DbConnection connection = db.CreateConnection();
execute this in a try-catch block. This will throw a exception if the database that your trying to open a connection does not exist.
Global Technology & Solutions