为什么我在此代码中出现"您的SQL语法中有错误"错误?

1 c# mysql sql

我正在尝试使用更新查询,但它显示以下语法错误:

"MySql.Data.MySqlClient.MySqlException:'您的SQL语法有错误;请查看与您的MariaDB服务器版本对应的手册,以便在'[Item Name] ='bulb'附近使用正确的语法,[数量类型] ='pcs',[数量] ='470',[项目价格(以卢比计算)] ='在第1行''

using (MySqlConnection connection = new MySqlConnection(con))
{
    try
    {
        connection.Open();
        using (MySqlCommand command = connection.CreateCommand())
        {
            command.CommandText = "UPDATE inventory Set [Item Name]=@itname,[Quantity Type]=@qtype,[Quantity]=@qty,[Item Price (in Rs.)]=@itprice,[Supplier]=@supl WHERE [pid]=@lpid";
            command.Parameters.AddWithValue("@lpid", lbl_dpid.Text);
            command.Parameters.AddWithValue("@itname", txtbox_itemname.Text);
            command.Parameters.AddWithValue("@qtype", cmbox_qtype.Text);
            command.Parameters.AddWithValue("@qty", txtbox_qty.Text);
            command.Parameters.AddWithValue("@itprice", txtbox_itprice.Text.ToString());
            command.Parameters.AddWithValue("@supl", txtbox_supplier.Text);

            DialogResult result = MessageBox.Show("Do You Want to Update?", "Update", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            if (result.Equals(DialogResult.OK))
            {
                command.ExecuteNonQuery();
                connection.Close();
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}
Run Code Online (Sandbox Code Playgroud)

在数据库表中,pid的数据类型,项目价格(以卢比为单位)和数量为int,其余为varchar. 这就是设计的样子

Dav*_*vid 8

MySQL不使用方括号:

UPDATE inventory Set [Item Name]=@itname
Run Code Online (Sandbox Code Playgroud)

它使用反向标记:

UPDATE inventory Set `Item Name`=@itname
Run Code Online (Sandbox Code Playgroud)

请记住,"SQL语法中的错误"消息始终指向SQL解析器首次混淆的确切字符.什么是"近"的开始.在这种情况下,那个[角色.