vb.net - "Error: Operator '&' is not defined for types 'String' and 'System.Windows.Forms.TextBox'." -


im getting error in both save , update button in .commandtext

"error: operator '&' not defined types 'string' , 'system.windows.forms.textbox'." 

i don't know error in both save , update buttons.

here code:

private sub btnsave_click(sender object, e eventargs) handles btnsave.click     try         cm             .connection = cn             .commandtext = "insert [edit$]values('" & txtid.text & "','" & txtfamilyname.text & "','" & txtgivenname.text & "','" & txtgender.text & "','" & txtdob.text & "','" & txtexamdate.text & "','" & txtexamtime.text & "','" & txtstreet.text & "','" & txthouse.text & "','" & txtplz.text & "','" & txtcity & "' )"             .executenonqueryasync()         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 & "' , given name = '" & txtgivenname.text & "'and gender = '" & txtgender.text & "'and dob = '" & txtdob.text & "'and exam date'" & txtexamdate.text & "'and exam time = '" & txtexamtime.text & "'and street name = '" & txtstreet.text & "'and house nr = '" & txthouse.text & "'and plz = '" & txtplz.text & "'and city = '" & txtcity & "'"             .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 

the answer easy:

you didn't call text-property every time used textbox value.

look @ txtcity variable:

"'and city = '" & txtcity & "'" 

should be

"'and city = '" & txtcity.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 -