I have the following string which holds the query I want to execute:
query = "UPDATE inventario"
+ " set descripcion = '" + descripcion + "',"
+ " set bodega = '" + bodega + "'"
+ " where codigo = " + codigo;
I get an Update statement syntax error but I dont see where is the error. Any help is appreciated.
columns “descripcion” and “bodega” are text type columns.
Well it’s probably because you’ve got multiple
setparts instead of using comma separation, and potentially because you don’t have quotes around thecodigovalue (if that’s another string)… but I’d strongly advise you not to create SQL like this anyway, with values directly in the SQL.Instead, use a prepared statement:
Using prepared statements has three immediate benefits: