-2
对于输入的每个密码和用户名,它显示相同的消息“用户名和密码正确”,请帮我检测密码错误。C#:在检测员工登录密码时出错
private void btn_Login_Click(object sender, EventArgs e)
{
connection.Open();
OleDbCommand command= new OleDbCommand();
command.Connection=connection;
command.CommandText="Select * from EmployeeData where Username ='"+txt_Username.Text+"' and Password='"+ txt_Password.Text+"'";
OleDbDataReader reader= command.ExecuteReader();
int count=0;
while(reader.Read());
{
count =count+1;
}
if (count == 1)
{
MessageBox.Show("Username and password is correct");
}
else if(count > 0)
{
MessageBox.Show("Username or password is NOT correct");
}
connection.Close();
}