title: VB.NET Connection string (Web.Config, App.Config)
body: <p>Really having an annoying time with connection strings.</p>
  
  <p>I have two projects together in a single solution. A Web forms application acting as the presentation layer, and a class library supporting it which will send and receive data from a database.
   </p>
  
  <p>-- The Employee Class within the Class Library Project --</p>
  
  <pre><code>Friend Class Employee
  
  Public Function GetEmployees() As DataSet
  
      Dim DBConnection As New SqlConnection(My_ConnectionString)
      Dim MyAdapter As New SqlDataAdapter("exec getEmployees", DBConnection)
  
      Dim EmployeeInfo As DataSet
      MyAdapter.Fill(EmployeeInfo, "EmployeeInfo")
  
      Return EmployeeInfo
  
  End Function
  
  End Class
  </code></pre>
  
  <p>Currently the application is telling me it cannot access "My_ConnectionString" which I have attempted to store within a config file for quick repeated access:</p>
  
  <pre><code>&lt;configuration&gt;
  
  &lt;system.web&gt;
    &lt;compilation debug="true" strict="false" explicit="true" targetFramework="4.5" /&gt;
    &lt;httpRuntime targetFramework="4.5"  /&gt;
  &lt;/system.web&gt;
  
   &lt;connectionStrings&gt;
     &lt;add name="My_ConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=My_DB;Integrated Security=True;"/&gt;
   &lt;/connectionStrings&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The web.config is part of the web form project and not the class library, are these projects unable to 'talk' to each other? Do I need to add a web / app config file to the class library to store a connection string within that project?</p>