接続文字列で本当に迷惑な時間を過ごしています。
1つのソリューションに2つのプロジェクトがあります。プレゼンテーション層として機能するWebフォームアプリケーションと、データベースとの間でデータを送受信するそれをサポートするクラスライブラリ。
-クラスライブラリプロジェクト内の従業員クラス-
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
現在、アプリケーションは、すばやく繰り返しアクセスするために構成ファイル内に保存しようとした「My_ConnectionString」にアクセスできないと言っています。
<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はWebフォームプロジェクトの一部であり、クラスライブラリではありません。これらのプロジェクトは、相互に「通信」できませんか?そのプロジェクト内に接続文字列を保存するために、Web /アプリ構成ファイルをクラスライブラリに追加する必要がありますか?