c# - Edit single item in database via textbox -
private void button1_click(object sender, eventargs e) { using (sqlconnection connection = new sqlconnection(connectionstring) { connection.open(); sqlcommand cmd = new sqlcommand("update dictionary set word=@word", connection); cmd.parameters.addwithvalue("@word", wordtextbox.text); cmd.executenonquery(); this.close(); } } i created way take selected value in listbox , add item text box on seperate form. there attempting give user way change word , have reflected in dataset created. when change word replaces every entry in dataset new word opposed specific entry. trying figure how specify change 1 item.
that because missing where clause in query. need use where clause in query update selected records :
eg : update dictionary set word=@word id=@id.
this example. have put clause per requirement.
hope helps.
Comments
Post a Comment