The company I work is considering to use the Enterprise Library Data Access Application Block. The problem is an internal policy that forces all company systems to get the connection string from a sql server.
Is there any way to just pass the connection string to the Data Access Application Block instead of getting it from the app.config or web.config?
I dont see any overloaded methods on the DatabaseFactory.CreateDatabase() method. Pointers please!
hello, i am facing problem passing connnection string to the entLib so i am using your method : public static Database CreateDatabase() { string connectionString = App_Settings.portalCnnStr; string dd = "System.Data.SqlClient"; return new GenericDatabase(connectionString,dd);
// dbProviderFactory = System.Data.SqlClient } But the GenericDatabase takes string,DbProviderFactory .. so how to pass second parameter?? i used several ways and in all it failed!!
None
0 Points
6 Posts
Passing connection string to Enterprise Library DAAB 3.1
Jun 11, 2007 05:37 PM|sk78|LINK
The company I work is considering to use the Enterprise Library Data Access Application Block. The problem is an internal policy that forces all company systems to get the connection string from a sql server.
Is there any way to just pass the connection string to the Data Access Application Block instead of getting it from the app.config or web.config?
I dont see any overloaded methods on the DatabaseFactory.CreateDatabase() method. Pointers please!
Enterprise Library 2.0 Introduction "Enterprise Library 2.0" configSections Application Programming Issue
Member
20 Points
75 Posts
Re: Passing connection string to Enterprise Library DAAB 3.1
Jun 18, 2007 07:50 PM|bc1016|LINK
You can write your own wrapper class to provide the CreateDatabase in this way by passing in the connection strings to the GenericDatabase() in DAAB:
It works for me.
Member
7 Points
54 Posts
Re: Passing connection string to Enterprise Library DAAB 3.1
Feb 09, 2009 04:25 PM|nasserdw|LINK
None
0 Points
7 Posts
Re: Passing connection string to Enterprise Library DAAB 3.1
May 26, 2009 12:26 PM|GTL|LINK
If you know that it's definitely an SQL database being used, you can just create a new SqlDatabase rather than GenericDatabase. Worked for me!
e.g:
Database _db = new SqlDatabase(connectionString);
None
0 Points
1 Post
Re: Passing connection string to Enterprise Library DAAB 3.1
May 03, 2011 02:07 PM|ocofre|LINK
Hello,
string dbFactory= "System.Data.SqlClient"
db = New GenericDatabase(connectionString, DbProviderFactories.GetFactory(dbFactory))