Search code examples
databaseenterprise-librarydatabase-connectionconnection-string

Open Microsoft.practices.EnterpriseLibrary database with just a connection string


I am using the Microsoft.Practices.EnterpriseLibrary Database tools and I'm having trouble creating a new database using just the connection string information.

Ideally I would like to do the following:

Database dbEngine = DatabaseFactory.CreateDatabase(
    "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;");

Is it possible to create a database using just the connection string?

If so, how can it be achieved?


Solution

  • You can also do

    
    Database mydb = new EnterpriseLibrary.Data.Sql.SqlDatabase("connection string here");
    

    and you'll retain the versatility of the Database object, but create it with a connection string.