How to delete local records that have been synched in UploadOnly direction RRS feed

  • Question

  • I have an Windows Mobile 5.0 application using SyncServices over WCF with Sql2005.

    I have the need to delete records from the mobile database after a given duration AND if the record has been synched. These records are synched with the Server in UploadOnly direction.

    My question is, how can I tell which records have been synched?

    Wednesday, May 19, 2010 3:09 PM


All replies

  • Hi,

    before we jump into the recommendataions/solutiohns, can you elabrate a bit what is your scenario, what you want to achieve in bit more details ? I suspect you probalby want the deletes occured on the local device won't sync to the SqlServer but want to get some confirmations from you.




    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Nina H Friday, May 21, 2010 6:54 AM
    • Unmarked as answer by gs_ham Wednesday, June 9, 2010 4:04 PM
    Wednesday, May 19, 2010 10:00 PM
  • Yunwen,

    Thanks for the reply. Yes that is correct. The mobile application is simply store and forward, no real logic. It merely collects data and sends it up to the server. We do not delete anything on the server side, so maintaining deletes via Sync is not necessary. So on the mobile client, after it can be verified that a record was indeed synched, we wish to remove it after some specified duration. So lets say if(record is synched and > 3 days old) {delete()}. And no the deletes that occur on the device do not need to sync with the server.  

    Thanks again for the prompt response.



    Thursday, May 20, 2010 1:28 AM
  • Hi Shane,

    this is not supported by the current release of the sync services. this can be handled at the sync application layer with the desired logic you need to fit your needs.

    depending on how complex your scenrio is ( e.g. can dml and sync happens concurrently at the client ), the complexity of the logic could vary also. a simple and probably most straitforward way is probaly hook with the changesSelected Event and remove the deleted records in the dataset so they wont be sent to the server at all. another way to deal with is to keep a copy of a clean local db and replace the current db with it after a successful sync ( and no new records  in the current db), so you won't need to do deletes at all.




    (Please alway testing your logic and the scenario before put into production envrioments)

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, May 21, 2010 10:17 AM
  • I was under the impression that after I deleted the records I could invoke AcceptChanges() and that would mean that server and client are in sync as opposed to intercepting the ChangesSelected event and checking the dataset for deleted rows.

    Either way, I still have the problem of knowing what can be deleted after a sync. Is there no way to determine if a record has been synced?

    Friday, May 21, 2010 1:27 PM
  • I ran into this issue as well. I eventually gave up using sync for the upload (I still use it to download lookup data). In my data collection table I have a bit field that specifies whether the field has been uploaded. For each record (or batch of records), I send the data, and receive an ack back that the upload was successful for each record. When I receive an ack for a record, I set the bit to true. Once the sync is complete, I delete the records with the flag set. Although using sync for the record upload would be the most desirable, I have not run into any problems with my current solution.

    Good luck,


    Monday, May 24, 2010 5:52 PM
  • Ok, so to be clear.

    Yunwen, is there no way to receive information related to the Sync from the WCF service? Information is being returned from the service to populate the SyncStatistics correct? Someone mentioned using a WCF callback but I read somewhere that that is not supported on compact framework?

    I just need a way to check if the record sent to the server failed and then mark it as such in the local sqlce database.

    FireTek's solution will work, however I would rather stay within the sync framework and let it handle all data transfers.



    Wednesday, June 9, 2010 4:01 PM
  • You can actually call localProvider.GetChanges after your upload sync and see what's included in the changes. The rows which are not included have been sent to server already.
    Friday, June 18, 2010 12:59 AM
  • Thanks Jin,

    I think JuneT's suggestion of using the ApplyChanges() within the WCF proxy is going to work best.


    Using that technique,, I should be able to get the conflicted rows and mark them accordingly in the local DB.

    • Marked as answer by gs_ham Wednesday, June 23, 2010 6:01 PM
    Wednesday, June 23, 2010 6:01 PM