新手在线求解答 为什么if语句没有执行
这是代码 为什么结果直接显示输入有误 为什么if里面的没有执行 string txt1 = "Data Source=pc2011091520fha;DataBase=学生;Integrated Security=SSPI;User Instance=False";
SqlConnection conn = new SqlConnection(txt1);
string sql = "select * from [zhuce]";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
bool s=reader["Z_no"].ToString() == textBox1.Text.Trim() && (reader["passw"].ToString() == textBox2.Text.Trim());
if (s ==true)
{
MessageBox.Show("登录成功!");
conn.Close();
reader.Close();
frmain fmain = new frmain();
fmain.Show();
textBox1.Text = "";
textBox2.Text = "";
}
else
{
MessageBox.Show("输入有误!"); break;