您好,我的代码有点问题。我收到此错误,这取决于
myReader = SelectCommand.ExecuteReader();
我真的不明白。
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“密码”附近使用正确的语法
MySqlConnection conn = new MySqlConnection("secretstring")
MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM userspassword where'" + this.loginuser.Text + "'and password'" + this.passworduser.Text, conn);
MySqlDataReader myReader;
conn.Open();
//myReader = SelectCommand.ExecuteReader();
myReader = SelectCommand.ExecuteReader();
int count = 0;
while (myReader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Correct");
Form2 pannel = new Form2();
pannel.Show();
Hide();
}
else if (count > 1)
{
MessageBox.Show("More then 1 user logged in");
}
else
MessageBox.Show("Incorrect password or username");
conn.Close();