[英]"Username or Password is not correct" - getting the same message
我試圖制作一個登錄頁面。 但是,它總是顯示此消息:
用戶名或密碼不正確
雖然我很確定我的用戶名和密碼是正確的。
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtbox_user.Text) || string.IsNullOrEmpty(txtbox_password.Text))
//txt_name.Text == String.IsNullOrEmpty || txt_family.Text == String.IsNullOrEmpty || txt_username.Text == String.IsNullOrEmpty || txt_password.Text == String.IsNullOrEmpty || txt_repeat.Text == String.IsNullOrEmpty || txt_mail.Text == String.IsNullOrEmpty)
{
MessageBox.Show("Plesae insert your username and password");
}
else
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = " select * from Login where UserName =' " + txtbox_user.Text + " ' and PassWord = ' " + txtbox_password.Text + " ' ";
OleDbDataReader reader = command.ExecuteReader();
int count = 0;
while (reader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Welcome!");
LearnerForm F2 = new LearnerForm();
F2.Show();
}
if (count > 1)
{
MessageBox.Show("Duplicate username or Password");
}
else
{
MessageBox.Show("Username or Password is not correct");
}
connection.Close();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.