C# 尽管使用System.Configuration,但无法识别ConfigurationManager
我正在为一个数据库编写一个前端程序,使用XAML作为UI,使用C作为逻辑。我正在尝试通过执行以下操作读取数据库:C# 尽管使用System.Configuration,但无法识别ConfigurationManager,c#,visual-studio-2010,configuration,C#,Visual Studio 2010,Configuration,我正在为一个数据库编写一个前端程序,使用XAML作为UI,使用C作为逻辑。我正在尝试通过执行以下操作读取数据库: //Declaring VFWPost table //Note: This table is used in the "VFW Posts" tab. DataTable tblVFWPost = new DataTable(); string connString1 = ConfigurationManager.ConnectionStrings["C:\Users\Sam Br
//Declaring VFWPost table
//Note: This table is used in the "VFW Posts" tab.
DataTable tblVFWPost = new DataTable();
string connString1 = ConfigurationManager.ConnectionStrings["C:\Users\Sam Brockmann\Documents\VSS Database.accdb"].ConnectionString;
string query1 = @"SELECT VFW Post #, Post Manager ID, Annual Due Date, Post Address, Post City, Post Zip Code,
Post Phone Number, Post Email FROM tblVFWPost";
//Fill the VFWPost Set with the data
using (SqlConnection conn1 = new SqlConnection(connString1))
{
SqlDataAdapter da1 = new SqlDataAdapter(query1, conn1);
da1.Fill(tblVFWPost);
}
//Setting VFWPost Listbox item source
List<DataRow> VFWPostList = tblVFWPost.AsEnumerable().ToList();
VFWPostListBox.ItemsSource = VFWPostList;
问题是VisualStudio拒绝识别ConfigurationManager类,尽管它使用System.Configuration;与我正在使用的其他名称空间同步。是否有ConfigurationManager类的替代方案可用于将数据库信息直接拉入我的程序?因为该类来自System.Configuration程序集。您需要将其作为全局程序集缓存中的引用添加到项目中。因为该类来自System.Configuration程序集。您需要将该程序集作为全局程序集缓存中的引用添加到项目中。您是否也将该程序集作为引用添加到项目中?您是否也将该程序集作为引用添加到项目中?冒着听起来愚蠢的风险,我该如何做?右键单击您的项目,选择“添加引用”。谢谢我很感激!冒着听起来愚蠢的风险,我该如何做呢?右键单击您的项目,选择添加引用。谢谢我很感激!