sql server - How to set the code to update the table in database -
i'm making system using visual studio express 2012 , use microsoft sql server have in visual studio think. problem is, when i'm trying run system,an error occur said "operator '&' not defined types 'string' , 'system.windows.forms.datagridview'." code.
imports system.data.sqlclient public class registration dim cn new sqlconnection("data source=(localdb)\v11.0;attachdbfilename=c:\users\user_pc\desktop\for fyp\computer lab requirement system\fyp3\fyp3\fyp.mdf;integrated security=true") dim cmd new sqlcommand dim dr sqldatareader private sub registration_load(sender object, e eventargs) handles mybase.load cmd.connection = cn end sub private sub btnregisterl_click(sender object, e eventargs) handles btnregisterl.click if txtidl.text <> "" , txtusernamel.text <> "" , txtpasswordl.text <> "" cn.open() cmd.commandtext = "update info set id = '" & txtidl.text & "',user = '" & txtusernamel.text & "',pass = '" & txtpasswordl.text & "'where id = '" & form1.datagridview1 & "' " cmd.executenonquery() cn.close() txtidl.text = "" txtusernamel.text = "" txtpasswordl.text = "" end if end sub end class i'm glad if there 1 me explain , teach me whats wrong coding above. i'm new in thing. thanks. :)
you hold primary key of data in gridview in 1 of columns , use in query, instead of below line have:
"'where id = '" & form1.datagridview1 & "' "
Comments
Post a Comment