我正在尝试获取帐户表的行数,以便我可以登录帐户,但 MySQL 参数没有添加这些值。
这是我的代码:
public int MyMethod(string username, string password)
{
int count = 0;
string query = "SELECT * FROM accounts WHERE username = '?user' AND password = '?pass' LIMIT 1;";
using (MySqlCommand cmd = new MySqlCommand(query, connector))
{
cmd.Parameters.Add(new MySqlParameter("?user", username));
cmd.Parameters.Add(new MySqlParameter("?pass", password));
count = int.Parse(cmd.ExecuteScalar().ToString());
}
return count;
}