Donate

Error 1064 Insert Statement Using MySQL Parameters In C#

Good evening!

The code above has a database field called desc which is a reserved word in SQL as an order by criteria.
dbQuery = String.Format(@"INSERT INTO accom_temp_hotelagencies(hotel_id, agency_id, hotel_webid, desc)VALUES(?HotelId, ?AgencyId, ?HotelWebId, ?Description)");
The solution is to enclose the field name desc with an acute or back quote. as shown in the code below:
dbQuery = String.Format(@"INSERT INTO accom_temp_hotelagencies(hotel_id, agency_id, hotel_webid, `desc`)VALUES(?HotelId, ?AgencyId, ?HotelWebId, ?Description)");  
Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid