//using System.Configuration;注意先添加其dll引用 private void button1_Click(object sender, EventArgs e) { string strConn = ConfigurationManager.ConnectionStrings[0].ConnectionString; MessageBox.Show(strConn); }