c# - SqlDataAdapter doesn't delete a record -


i use dataset store data , sqldataadapter work database.

for change records in database first edit rows (insert,edit,delete) datatable in dataset ..

then

datarow dr = datasetmain.tables["tbl_error"].select("error_name='" + error.name + "'")[0];             datasetmain.tables["tbl_error"].rows.remove(dr);     sqldataadapter adp = new sqldataadapter("select * tbl_error", svariable._databaseconnectionstring);                 sqlcommandbuilder bui = new sqlcommandbuilder(adp);     adp.update(datasetname,tbl_error); 

for insert or edit record every thing work charm ... delete not work ..

i`m sure row in tbl_error deleted adp.update won't delete database ...

how can find problem ?

calling rows.remove() equivalent call rows.delete() + acceptchanges(). due acceptchanges, update() don't modification.

then replace:

datasetmain.tables["tbl_error"].rows.remove(dr); 

by

dr.delete() 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -