.net - DataAdapter.Update not doing so but suggesting is has -
i'm moving data between sql server , local sql server compact database. i'm populating dataset single table using standard dataadapter.fill etc. pass dataset function attemps update local sql compact db.
so want extract dataset single datatable (for now) on db (sql server) , throw db (sql compact).
(yes know there tools , sync framework there other reasons approach)
to detect changes i'm using data version (of own rolling) , id. if id > highest 1 have mark row added, otherwise if dataversion of row higher mark row changed.
if (convert.toint32(row["settingid"]) > id) { row.acceptchanges(); row.setadded(); } else if(convert.toint32(row["dataversion"]) > dv) { row.acceptchanges(); row.setmodified(); }
deletes handled differently not important here.
i make sqlceadapter try , insert / update records ce database.
using (sqlcedataadapter ad = new sqlcedataadapter("select * " + tablename, connection)) { using (sqlcecommandbuilder cb = new sqlcecommandbuilder(ad)) { cb.conflictoption = conflictoption.overwritechanges; ad.updatecommand = (sqlcecommand)cb.getupdatecommand(); ad.insertcommand = (sqlcecommand)cb.getinsertcommand(); ad.fillschema(ds, schematype.source); //tried both types , not doing this. ad.rowupdating += ad_rowupdating; ad.rowupdated += ad_rowupdated; int result = ad.update(ds, tablename); } } for inserts works fine - come through.
updates not work.
if check rows of data table being passed in (i.e. after using statement above) have staus of changed correct. update method returns correct number of rows updated have not changed (it lies!). there no exception.
i subscribe rowupdating , rowupdated events , rowupdating method fire each row. when @ sqlcerowupdatedeventargs each row has status of skipcurrentrow , command object null. rowupdated event never fires.
why has status of modified been lost , skipcurrentrow being used ?
if modify , create destination dataset , update rows source both events fire , updates take place. again no idea differences are. i've tried comparing properties of both datasets , datatables , seem identical.
i think should simple 1 of forehead->desk interface situations.
any ideas ?
Comments
Post a Comment