Ich versuche, meine MYSQL-Tabelle mit diesem Code zu aktualisieren.MySQL-Abfrage funktioniert nicht (C#)
string sqlquery = String.Format("if exists(select 1 from orders where id =\" {0}\") begin update orders set customer_id = \"{1}\", total = \"{2}\", fio = \"{3}\", adress =\" {4}\" where id = \"{0}\" end else begin insert into orders (id, customer_id, total, fio, adress) values(\"{0}\", \"{1}\", \"{2}\", \"{3}\", \"{4}\") end", id, customer_id, total, fio, adress);
MySqlCommand addCommand2 = new MySqlCommand(sqlquery.ToString(), connection);
addCommand2.ExecuteNonQuery();
Aber ich habe diesen Fehler
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if exists(select 1 from orders where id = 1913) begin update orders set custome' at line 1
Datenbank
was falsch in Abfrage?
Danke für Ihre Hilfe!
Posten Sie hier, was Sie in der 'sqlquery' zur Laufzeit zu bekommen. – feeeper
Ihr Spaltenname ist '1'? –
Ich bekomme Fehler, wenn Code startet @ feeeper – Eugene