【问题标题】:C# INSERT ERROR MYSQL Server Version For the Right Syntax to user nearC# INSERT ERROR MYSQL Server Version For the Right Syntax to user near
【发布时间】:2015-12-26 06:36:53
【问题描述】:

这是我的错误

您的 SQL 语法有错误;检查手册 对应于您的 MySql 服务器版本,以便使用正确的语法 在第 1 行的 'Key) VALUES ('biaprot','4E0658D00F47D86D19A0E792E...' 附近。

我的代码:

private bool validate_register(string user, string pass)
    {
        db_connection();
        MySqlCommand cmd = new MySqlCommand();
        cmd.CommandText = "INSERT INTO accounts (Username,Key) VALUES (@user,@pass)";
        cmd.Parameters.AddWithValue("@user", user);
        cmd.Parameters.AddWithValue("@pass", pass);
        cmd.Connection = connect;
        MySqlDataReader login = cmd.ExecuteReader();
        if (login.Read())
        {
            connect.Close();
            return true;
        }
        else
        {
            connect.Close();
            return false;
        }
    }
private void button1_Click(object sender, EventArgs e)
    {
        string user = textBox1.Text;
        string pass = GetWP(textBox3.Text);
        string pass2 = GetWP(textBox4.Text);

我使用 WhirlPool Hash 来编码我的密码。请帮助我,谢谢你

【问题讨论】:

标签: c# mysql md5 whirlpool


【解决方案1】:

key 是 mysql 关键字,要将其用作列名,您必须在反引号中引用它

cmd.CommandText = "INSERT INTO accounts (Username,`Key`) VALUES (@user,@pass)";

【讨论】:

  • 谢谢!我修复了这个:)
猜你喜欢
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-27
  • 2015-04-24
  • 1970-01-01
相关资源
最近更新 更多