tsql - Problems with update statement in c# -
im relatively new programming in c# , have come across problem during creating update statement, managed insert statement run there seems error confirmation of id, form looks database , displays information in datagridview, once record selected information displayed textboxes.
private void btnsave_click(object sender, eventargs e) { dbcon.connectionstring = "provider=microsoft.ace.oledb.12.0; data source=elemental.accdb"; dbcon.open(); string sql = "update tblopencalls set [callid]= @callid, [staffid]= @staffid, [problemdesc] = @desc, [problemtype] = @problemtype, [department] = @department, [location] = @location, [urgency]= @urgency, [datecreated] = @created, [dateamend] = @amend, [allocatedto] = @allocate, [forename] = @forename, [surname] = @surname [callid]= $callid"; oledbcommand cmd = new oledbcommand(sql, dbcon); cmd.parameters.addwithvalue("@callid", txt_callid.text); cmd.parameters.addwithvalue("@staffid", txt_staffid); cmd.parameters.addwithvalue("@desc", txt_problemdesc); cmd.parameters.addwithvalue("@problemtype", txt_problemtype); cmd.parameters.addwithvalue("@department", txt_department); cmd.parameters.addwithvalue("@location", txt_location); cmd.parameters.addwithvalue("@urgency", txt_urgency); cmd.parameters.addwithvalue("@created", txt_created); cmd.parameters.addwithvalue("@amend", txt_amended); cmd.parameters.addwithvalue("@allocate", txt_allocate); cmd.parameters.addwithvalue("@forename", txt_forename); cmd.parameters.addwithvalue("@surname", txt_surname); cmd.executenonquery(); dbcon.close(); messagebox.show("field updated", "update"); }
the error have got syntax error in query expression '[callid]= $callid'. simple have missed out in advance advice.
you seem have typo;
where [callid]= $callid
should be
where [callid]= @callid
Comments
Post a Comment