Syntax error in INSERT INTO statement. in VB.net 2008 -
i have been problem week , searching every existing forum reply maybe time post own problem.
acessdate datetimepicker command , barcodeno in number , year in number
class="lang-vb prettyprint-override">private sub btn_save_click(byval sender system.object, byval e system.eventargs) handles btn_save.click dim cmd new oledb.oledbcommand if not con.state = connectionstate.open con.open() end if 'cmd.connection = con cmd.commandtext = "insert book_entry (accessdate,barcodeno,accessno,callno,author,subject,title,edition,pub,publi_place,[year],pages,size,vendor,cost,remark) values (@accessdate1,@barcodeno1,@accessno1,@callno1,@author1,@subject1,@title1,@edition1,@pub1,@publi_place1,@year1,@pages1,@size1,@vendor1,@cost1,@remark1)" cmd.connection = con cmd.parameters.addwithvalue("@accessdate1", dtpicker1.text) cmd.parameters.addwithvalue("@barcodeno1", txt_barcode.text) cmd.parameters.addwithvalue("@accessno1", txt_accession.text) cmd.parameters.addwithvalue("@callno1", txt_callno.text) cmd.parameters.addwithvalue("@author1", txt_author.text) cmd.parameters.addwithvalue("@subject1", cmb_subject.text) cmd.parameters.addwithvalue("@title1", txt_title.text) cmd.parameters.addwithvalue("@edition1", txt_edition.text) cmd.parameters.addwithvalue("@pub", cmb_publication.text) cmd.parameters.addwithvalue("@publi_place1", txt_publiplace.text) cmd.parameters.addwithvalue("@year1", txt_year.text) cmd.parameters.addwithvalue("@pages1", txt_pages.text) cmd.parameters.addwithvalue("@size1", txt_size.text) cmd.parameters.addwithvalue("@vendor1", cmb_vendor.text) cmd.parameters.addwithvalue("@cost1", txt_cost.text) cmd.parameters.addwithvalue("@remark1", txt_remark.text) cmd.executenonquery() msgbox("successfully inserted", msgboxstyle.information) con.close() end sub
i'm not sure if subject reserved name or not in access using reserved names field names provide syntax error.
in case, alter 6th column's name subject else isn't reserved , trick.
otherwise, query seems legit.
hope solve problem.
vb.net
No comments:
Post a Comment