C# 中的 ConfigurationManager类引用方法
2015-11-21 15:57
435 查看
c#添加了Configuration;后,竟然找不到 ConfigurationManager 这个类,后来才发现:虽然引用了using System.Configuration;这个包,但是还是不行的。
后来终于找到一个解决方法,就是在解决方案资源管理器里找到类文件选择“引用”,然后右击选择“添加引用”,并且从 .net 中找到System.Configuration把它加上去就OK啦实例:DataGridView显示数据 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DevExpress.XtraEditors; using System.Data.SqlClient; using System.Configuration; namespace WindowsApplication1 { public partial class XtraForm1 : DevExpress.XtraEditors.XtraForm { public XtraForm1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string customers = "select * from Customers"; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["northwind"].ConnectionString)) { DataSet dt = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(customers, con); da.Fill(dt, "Customers"); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = dt; dataGridView1.DataMember = "Customers"; } } } }
相关文章推荐
- c#绘制曲线图遇到的问题
- C#基础篇总结(二)
- c#操作Excel(2)
- C# 设计时动态改变实体在PropertyGrid中显示出来的属性
- C# 自定义属性在propertyGrid控件中显示
- C# 自定义属性在propertyGrid控件中显示
- C# 设计时动态改变实体在PropertyGrid中显示出来的属性
- DirectX天空球和天空盒子模型
- 轻松学习C#的运算符
- Interview Q&A - 两个字符串整数相加返回和的字符串(C#)
- 轻松学习C#的预定义数据类型
- C# Winform中WndProc 函数作用
- C#获取网卡信息
- c#文件操作大全
- C#与XML Schema的问题
- Xml Schema:C#访问在complextype中插入新元素
- C#中用schema验证xml的合法性
- 简介C#读取XML的两种方式
- C#读写xml文件
- XSD(XML Schema Definition)用法实例介绍以及C#使用xsd文件验证XML格式