VB.net & Access query -
VB.net & Access query -
im doing vb.net project college , want create new access record using textboxes, masked textboxes , richtextboxes using vb gui. maintain getting exception:
"an unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dll additional information: syntax error in insert statement."
here code working on other forms
private sub btnsavenew_click(sender object, e eventargs) handles btnsavenew.click dim objrow datarow objrow = objdataset.tables("tblengineersreport").newrow objrow.item("to") = txtto.text objrow.item("date_carried_out") = txtcompleteddate.text objrow.item("description_of_work") = txtworkdescription.text objrow.item("comment") = txtcomment.text objrow.item("quantity1") = txtquantity1.text objrow.item("quantity2") = txtquantity2.text objrow.item("quantity3") = txtquantity3.text objrow.item("quantity4") = txtquantity4.text objrow.item("item_description1") = txtdescription.text objrow.item("item_description2") = txtdescription2.text objrow.item("item_description3") = txtdescription3.text objrow.item("item_description4") = txtdescription4.text objrow.item("unit_price1") = txtunitprice1.text objrow.item("unit_price2") = txtunitprice2.text objrow.item("unit_price3") = txtunitprice3.text objrow.item("unit_price4") = txtunitprice4.text objrow.item("rate1") = txtrate1.text objrow.item("rate2") = txtrate2.text objrow.item("rate3") = txtrate3.text objrow.item("labour1") = txtdescription5.text objrow.item("labour2") = txtdescription6.text objrow.item("labour3") = txtdescription7.text objrow.item("hours_worked1") = txthours1.text objrow.item("hours_worked2") = txthours2.text objrow.item("hours_worked3") = txthours3.text objdataset.tables("tblengineersreport").rows.add(objrow) objengineerda.update(objdataset, "tblengineersreport") retrieve() messagebox.show("new record added") cbojobid.enabled = true end sub the quanity textboxes downwards hours worked contained within table layout panel , wondering have record not saving?
looking @ names of columns notice have column named to. reserved keyword in ms-access , autogenerated queries adapter have syntax error if don't tell oledbcommandbuilder encapsulate column names appropriate quoteprefix , quotesuffix string.
you need add together code, after declaration , initialization of oledbcommandbuilder-
dim builder = new oledbcommandbuilder(objengineerda) builder.quoteprefix = "[" builder.quotesuffix = "]" vb.net
Comments
Post a Comment