真的很急 恳请各位高手帮忙~~
这是我设置登录的,为什么if里面的语句没有执行,显示的就是”输入有误“ 我是2010版C#private void button1_Click(object sender, EventArgs e)
{
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;
}
}
}