How to update a MS Access database in vb.net -


hi i'm having trouble updating 1 of tables using vb.net when click on button update data base give me error "system.data.oledb.oledbexception: no value given 1 or more required parameters." here code

protected sub button6_click(byval sender object, byval e system.eventargs) handles button6.click     dim aconnection new oledbconnection     dim acommand new oledbcommand     dim sqlquery, aconnectionstring string     dim text string = textbox1.text     dim adataadapter new oledbdataadapter     dim adatareader new dataset     sqlquery = "update review set report='yes' text='" & text & "'"     aconnectionstring = "provider=microsoft.ace.oledb.12.0;data source=" & server.mappath("app_data/bookreviewwebsite.accdb")     aconnection = new oledbconnection(aconnectionstring)     aconnection.open()      acommand = new oledbcommand(sqlquery, aconnection)      acommand.executenonquery()       label15.text = "review has been reported"      aconnection.close()  end sub 

review, report , text. here have 2 fields , table name, should check if database contains table named review , if, in table, there 2 field named report , text.

if have table , these fields, need enclose word text square brackets because word text reserved keyword in access 2007.

last, not least of problems query string itself. concatenating strings in way source of errors. if have single quote in 'text' variable results impredictable , range syntax error sql injection

sqlquery = "update review set report='yes' [text]=?" acommand = new oledbcommand(sqlquery, aconnection) acommand.parameter.addwithvalue("@p1", text) acommand.executenonquery() 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -