繁体   English   中英

尽管使用System.Configuration仍无法识别ConfigurationManager

[英]ConfigurationManager unrecognized despite using System.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 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;

问题是,尽管“使用System.Configuration”,Visual Studio仍拒绝识别ConfigurationManager类。 与我正在使用的其他名称空间。 是否有ConfigurationManager类的替代方法,可用于直接将数据库信息提取到我的程序中?

文档所述 ,该类来自System.Configuration程序集。 您需要将其添加到项目中,以作为全局程序集缓存中的引用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM