Wednesday, July 24, 2013

Error 1064 Insert statement using MySQL Parameters (C#)

Code:
dbQuery = String.Format(@"INSERT INTO accom_temp_hotelagencies(hotel_id, agency_id, hotel_webid, desc)VALUES(?HotelId, ?AgencyId, ?HotelWebId, ?Description)");
The code above has a database field called desc which is a reserved word in
SQL as an order by criteria.

The solution is to enclose the field name desc with an acute or back quote
as shown in the code below:
Code:
dbQuery = String.Format(@"INSERT INTO accom_temp_hotelagencies(hotel_id, agency_id, hotel_webid, `desc`)VALUES(?HotelId, ?AgencyId, ?HotelWebId, ?Description)");  
Cheers!

0 comments:

Post a Comment