c# - Trouble with INSERT INTO statement -
i can't seem figure out why keep getting syntax error in insert statement
.
the code below.
static void abschangeeventstable(string controlnumber, string currentstatus) { using (var connection = new oledbconnection(straccessconnabstracting)) using (var command = connection.createcommand()) { connection.open(); command.commandtext = "insert events (date_time, details, regarding, user, control_number) values (@date_time, @details, @regarding, @user, @control_number)"; command.parameters.addwithvalue("@date_time", datetime.now); command.parameters.addwithvalue("@details", "old:"+currentstatus+" new: received fax"); command.parameters.addwithvalue("@regarding", "status changed"); command.parameters.addwithvalue("@user", "system"); command.parameters.addwithvalue("@control_number", controlnumber); try { command.executenonquery(); } catch (system.exception ex) { throw; } } }
user
reserved keyword, need wrap in square brackets:
insert events (date_time, details, regarding, [user], control_number) values (@date_time, @details, @regarding, @user, @control_number)
i'd recommend renaming column avoid need square brackets every time reference it.
Comments
Post a Comment