title: Why am I getting a "You have an error in your SQL syntax" error in this code?
body: <p>I'm trying to use the update query but it shows the following syntax error:</p>
  
  <blockquote>
    <p>"MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[Item Name]='bulb',[Quantity Type]='pcs',[Quantity]='470',[Item Price (in Rs.)]=' at line 1'"</p>
  </blockquote>
  
  <pre><code>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);
      }
  }
  </code></pre>
  
  <p>In the database table, Data Type for pid, item Price (in Rs.) and Quantity is int and rest is varchar.
  <a href="https://i.stack.imgur.com/MiAQg.png" rel="nofollow noreferrer">This is what the design looks like</a></p>