If you are creating your class library and it requires a connection string called "ConnectionString", if the project you are calling it has a connection string in the configuration file of the Web application "ConnectionString", then this should be fine.
So use your project names. Your CLP class project with a data access code will establish a connection using the string "ConnectionString":
_serverConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
and then you encode this connection.
In the web.config file in your web project ("WP"), you add the following:
<connectionStrings><add name="ConnectionString" connectionString="Data Source=.\SQL2008;Integrated Security=True" providerName="System.Data.SqlClient" /></connectionStrings>
Obviously, pointing to the data source, etc. that you are using for the WP project.
Hope this helps.
source
share