public void Find(string userName, string password)
{
string query = "SELECT COUNT(*) FROM user WHERE username =\'" + userName + "\', \'" + GetMd5Sum(password) + "\'";
MySqlCommand cmd = new MySqlCommand(query, connection);
try
{
//This will return 1 if the username and password exist.
//It will return 0 if the username and password are not found.
int count = (int)cmd.ExecuteScalar();
if (count > 0)
MessageBox.Show("You have succesfully logged in!");
else
MessageBox.Show("Incorrect username or password.");
connection.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
}
我认为这就是问题所在。谁能解释或帮助我解决这个错误?
错误是:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“C8059E2Ec7419F590E79D7F1B774BFE6”附近使用正确的语法