Really with annoying time with connection strings.
I have two projects together in one solution. A web form application that acts as a presentation layer, and a class library that supports it, which will send and receive data from the database.
- An employee class within the class library project -
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
Currently, the application tells me that it cannot access the "My_ConnectionString", which I tried to save in the configuration file for quick re-access:
<configuration> <system.web> <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> <connectionStrings> <add name="My_ConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=My_DB;Integrated Security=True;"/> </connectionStrings> </configuration>
Web.config is part of a web form project, not a class library, are these projects unable to "talk" to each other? Do I need to add a web application configuration file to the class library to store the connection string in this project?
source share