对于我输入的每个密码和用户名,它显示相同的消息“用户名和密码正确”,请帮我检测密码不正确。
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();
}
在线while(reader.Read());
删除
;
从头到尾
while(reader.Read()) { count =count+1; }
是真的
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句