“System.Data.SqlClient.SqlException”类型的未经处理的异常在 System.Data.dll 中发生
本人新手一个 刚刚入学c# 写的一个连接sql登录界面,为什么启动后登录时就出现下面红色代码错误。终止运行了
SqlConnection conn = db.Camcon();
SqlCommand cmd = new SqlCommand("select coun(*) from register where id='" + textBox1.Text + "'and pwd='" + textBox2.Text + "'", conn);
conn.Open();
int a = Convert.ToInt32(cmd.ExecuteScalar());
if (a >0)
{
conn.Close();
MessageBox.Show("登录成功", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("用户名或密码错误", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}