Deletion problem
-
2012年2月20日 下午 01:43
Good day!
I have successfully implemented MS Sync Framework between SQL Server 2008 and SQL CE for my application, but I have one problem though: when I delete a row in the SQL CE it is mirrored in the Server, but when I delete a row in the server, instead of removing it from the CE too, it is rewritten on the server.
My code can be seen here.
Your help would be greatly appreciated!
所有回覆
-
2012年2月20日 下午 01:52版主
have you updated the same row on the client before you deleted on the server?
try subscribing to the AppliedChangeFailed event of the providers and check for conflicts.
or subscribe to the ChangesSelected event of the server provider and check to see if the delete is actually selected.
-
2012年2月20日 下午 04:09
The ChangesApplied event of the server provider does indeed registered by the Sync Framework when I delete something in the CE db, but not the other way arround.
So, the delete is not selected. How can I repair that?
-
2012年2月20日 下午 05:01版主Change your filter clause to use the alias of the change tracking table. E.g., CT.Id instead of login.id
-
2012年2月20日 下午 06:57
By doing that it just returned an error, but nevermind! I have implemented GUIDs as primary keys and all the problems are gone.
Thank you for your help though, I did learn useful things from your answers.
-
2012年2月20日 下午 11:32版主
nice to hear that. in the future, i would still suggest you do your filtering as much as possible against the change tracking table.
when a row is delete, it is no longer in the base table you are synching and the only record you have of that row is the deletion record in the change tracking table. naturally, if you apply the filter against the base table, you get no results since the row is no longer there in the first place. ie., if you have an login.id=1, then you delete row 1 from logins table, when you apply the filter login.id=1, it wont return anything because the row is no longer there. the change tracking table still have a record of the deletion though.
-
2012年4月12日 上午 01:37Wow, I never would have thought to create a filter against the _tracking table but it makes sense for any deleted data. It actually makes perfect sense whenever your filter is against PK/FK as they should always be in the tracking tables (unless you pull the Guid switcheroo). I'm mostly just writing this to help me remember but thanks again.

