MYSQL SQL syntax error c# -
i have error in sql statement. query:
mysqlcommand cmd = new mysqlcommand("insert bills (bill_number,bill_date,bill_from,bill_note,bill_taxrate,bill_disrate,bill_entrydate,cus_sup,by,archived) values(" + txbbillnumber.text + ",'" + datetime.parse(txbbilldate.text).year + "-" + datetime.parse(txbbilldate.text).month + "-" + datetime.parse(txbbilldate.text).day + "'," + sup_id + ",'" + txb_note.text + "'," + taxrate + "," + disrate + ",'" + datetime.now.year + "-" + datetime.now.month + "-" + datetime.now.day + "'," + bills.cus_sup + ",0,0)", objconn); cmd.executenonquery();
and in image error , bills table structure:
one problem word by use column reserved keyword (both in mysql , sql standard in general). use have enclose in backticks `` or double-quotes " ".
also, string values need between single-quotes applicable, think got that.
on side note should using parametrized queries instead of concatenating. see question example: c# mysql insert parameters
Comments
Post a Comment