Update Table only works once in datagridview (c#) -
i have datagridview in have made cells editable. once user has entered text, hit "update" button, updates database.
the problem whenever open application, update first time. when try make more modification , click "update" button, fails update database. here code. please suggest solution
private void form1_load_1(object sender, eventargs e) { con.open(); sda = new sqldataadapter("select * name", con); ds = new system.data.dataset(); sda.fill(ds); datagridview1.datasource = ds.tables[0]; } private void button1_click(object sender, eventargs e) { scb = new sqlcommandbuilder(sda); sda.update(ds); }
actually, there nothing wrong code mentioned. instead there section causing db not updated.
i kept refresh button code -
private void button2_click(object sender, eventargs e) { sda = new sqldataadapter("select * name", con); datatable dt = new datatable(); sda.fill(dt); datagridview1.datasource = dt; }
seems reverted update original db content. removing worked successfully.
Comments
Post a Comment