locked
MS Sync: Upload data after recreate local SQL Ce database RRS feed

  • Question

  • Hello

    I have a central database and many SQL Ce databases. 

    Each time a local database is created, I need to download some data from central server (table A) to the local one. After this download (that happens only once, when the local database is created) is finished, the local databases will change  the data in table A and upload it to the server using MS Sync. Using this approach I encounter the problem mentioned here.

    Right now, when client is created I read data from server and add it to the local table (no MS Sync). Basically is only one row of data from table A, which has a primary key of type int. The client changes the data and when sync process is triggered it uploads the data to the central server successfully.

    If I delete the local database and restart the process, no data is uploaded back to the central server. Why is that?

    Table A: 

    Id: int primary key

    Name: nvarchar[200]

    Index: int

    These are the steps:

    Central server: table A: 1 Client1 100

    I create the local database and download the data:

    Local server: table A: 1 Client1 100

    Changes happen locally and are uploaded on central server:

    Local server: table A: 1 Client1 200

    Central server: table A: 1 Client1 200

    Now I delete and recreate the local database. I insert the existing values from the server locally:

    Local server: table A: 1 Client1 200

    Client changes some data locally:1 Client1 300. And now when I trigger the sync process, no data is uploaded. What happens?


    sb_angela


    • Edited by sb_angela Tuesday, March 20, 2012 6:44 AM
    Tuesday, March 20, 2012 6:40 AM

Answers

  • you can set the conflict resolution to have the client win the conflict.

    but i would suggest not to prepopulate the client table outside of sync. if you have a million rows in there, you would have run to a million conflicts that needs to be resolved individually.

    • Marked as answer by sb_angela Wednesday, March 21, 2012 1:01 PM
    Tuesday, March 20, 2012 10:13 AM

All replies

  • can you subscribe to the ApplyChangesFailed  event and see if it show something there?

    if your process is prepopulating the client database with rows from the server outside of sync framework,  then your first sync would actually cause conflicts.

    assuming you have row id 1 in server, you create a local db and copy row id 1 to it...then you provision, neither the server nor the client knows that the rows they have are the same.

    when you sync the client, it will send row id 1 to server and that will fire a confict.

    Tuesday, March 20, 2012 8:54 AM
  • Hello

    Thank you very. I have subscribed to ApplyChangesFailed event and I have a  LocalInsertRemoteInsert confict.

    This is due to the fact that I have downloaded the row from the server and added it to the client. Afterwards client has change the data locally and when uploads starts it tries to insert the data to the server, instead of triggering an update.

    Can an update be forced in this situation? I have used ApplyAction.RetryWithForceWrite and it did the work.


    sb_angela


    • Edited by sb_angela Tuesday, March 20, 2012 10:12 AM
    Tuesday, March 20, 2012 9:22 AM
  • you can set the conflict resolution to have the client win the conflict.

    but i would suggest not to prepopulate the client table outside of sync. if you have a million rows in there, you would have run to a million conflicts that needs to be resolved individually.

    • Marked as answer by sb_angela Wednesday, March 21, 2012 1:01 PM
    Tuesday, March 20, 2012 10:13 AM