Set ConnectionString of Enterprise Library 4.1 at class library from web.config

Hi Experts,,

I have created a new project having 2 projects ( web and class library). However i need to have all data access classes embedded on the class library so i need to pass the connection string from the web.config to class library then assign to enterprise library database factory then execute.

What is the best way for doing this ??

Thanks
LVL 7
Abu HamdanEnterprise Architect, PM ExpertAsked:
Who is Participating?
 
Abu HamdanEnterprise Architect, PM ExpertAuthor Commented:
Problem solved by using this code:

   public static Database CreateDatabase()
        {
            string connectionString = App_Settings.portalCnnStr;
            DbProviderFactory provider =
            DbProviderFactories.GetFactory("System.Data.SqlClient");
            return new GenericDatabase(connectionString, provider);   // dbProviderFactory = System.Data.SqlClient
        }


cheers!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.