MySQL String Error in insert into Statement
When passing values, looking at C# code directly passing string value, error reported showing matching column not found
1 | command += "INSERT INTO " + TableName + "(data_id,data_desc,data_price) VALUES(" + ids[i] + ", " + description[i] + "," + price[i] + ");"+"\r\n"; |
After the running error, I found that I didn’t consider that the command is passed completely in string form. At this time, the string passed by description does not have double quotes “ “, the string form of the command is:
1 | "insert into table (data_id,data_desc,data_price) |
You can see that description has no double quotes so the command is wrong. You need to modify the command description to add single quotes.
1 | ", '" + description[i] + "' ," |
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.


