in table there 1 xml column. want fetch xml data in 1 textbox , make corrections , update it:
private void button2_click(object sender, eventargs e) { con.open(); string str = "select c1 tablename c2='" + txt1.text+ "'"; sqlcommand cmd1 = new sqlcommand(str, con); xmlreader xml = cmd1.executexmlreader(); xml.read(); txt2.text = xml.readouterxml(); xmldocument doc = new xmldocument(); doc.preservewhitespace = true; doc.loadxml(txt2.text); }
now want make changes , update in database. when try change in textbox not work. how can make changes , update in database? please help
update
using (sqlconnection connection = new sqlconnection(connectionstring)) using (sqlcommand command = connection.createcommand()) { command.commandtext = "update tablename set c1 = @c1 c2 = @c2 "; command.parameters.addwithvalue("@c1", textbox2.text); command.parameters.addwithvalue("@c2", textbox1.text); connection.open(); command.executenonquery(); connection.close(); }
Comments
Post a Comment