Deletion problem RRS feed

  • Question

  • 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!

    Monday, February 20, 2012 1:43 PM

All replies

  • 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.

    Monday, February 20, 2012 1:52 PM
  • 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?

    Monday, February 20, 2012 4:09 PM
  • Change your filter clause to use the alias of the change tracking table. E.g., CT.Id instead of login.id
    Monday, February 20, 2012 5:01 PM
  • 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.

    Monday, February 20, 2012 6:57 PM
  • 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.

    Monday, February 20, 2012 11:32 PM
  • Wow, 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.
    Thursday, April 12, 2012 1:37 AM