vb.net - Erorr: Syntax error (missing operators) in query expression? -


when ever click on update button showing me error "syntax error (missing operators) in query expression" save , refresh functions working fine. don't know syntax error in update button. here code:

private sub filldatagridview(byval query string)     da = new oledbdataadapter(query, cn)     dt.clear()     da.fill(dt)     datagridview1         .datasource = dt         .columns(0).headertext = "id"         .columns(1).headertext = "name"         .columns(2).headertext = "age"         .columns(1).autosizemode = datagridviewautosizecolumnmode.fill     end end sub  private sub btnsearch_click(sender object, e eventargs) handles btnsearch.click     try         filldatagridview("select * [edit$] id='" & txtid.text & "'")         txtfamilyname.text = dt.rows(0).item(1)     catch ex exception         msgbox(ex.message, msgboxstyle.critical, text)     end try end sub  private sub btnsave_click(sender object, e eventargs) handles btnsave.click     try         cm             .connection = cn             .commandtext = "insert [edit$]values('" & txtid.text & "','" & txtfamilyname.text & "', '" & txtage.text & "')"             .executenonquery()         end         filldatagridview("select * [edit$]")     catch ex exception         msgbox(ex.message, msgboxstyle.critical, text)         return     end try     msgbox("succefully saved!", msgboxstyle.information, text) end sub  private sub btnupdate_click(sender object, e eventargs) handles btnupdate.click     try         cm             .connection = cn             .commandtext = "update [edit$] set [family name] = '" & txtfamilyname.text & "' id ='" & txtid.text & "' age= '" & txtage.text & "'"             .executenonquery()         end         filldatagridview("select * [edit$]")     catch ex exception         msgbox(ex.message, msgboxstyle.information, text)         return     end try     msgbox("succesfully updated!", msgboxstyle.information, text) end sub 

use and where clause between 2 or more conditions

 id ='" & txtid.text & "' , age= '" & txtage.text & "'" 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -