private void d4_Click(object sender, EventArgs e)//联系查询
{
String str = ConfigurationManager.ConnectionStrings["conn"].ToString();//这处出现问题
SqlConnection conn = new SqlConnection(str);
if (ConnectionState.Closed == conn.State)
{
conn.Open();
}
String myselect = "select * from information where cno='" + text14.Text.Trim() + "'";
SqlCommand comm=new SqlCommand (myselect,conn);
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
text14.Text = reader[0].ToString();
text15.Text = reader[1].ToString();
text16.Text = reader[2].ToString();
text17.Text = reader[3].ToString();
text18.Text = reader[4].ToString();
}
}
VS没有其他无错,没有报错,只有这个问题
自己没有找到正确的解法
有没有配置连接字符串,还有连接字符串变量名称是不是conn