locked
Difference between initial and subsequent synchronizations RRS feed

  • Question

  • Hi all.

    I'm trying to synchronize SQL Ce on a Windows Mobile Device with SQL 2005 database.
    I want that the first time they synchronize, regardless of tracking, clients download all data. And after that i just want to download difference.

    I tried to add  SyncTables with Snapshot direction at the first time, and to change it to DownloadOnly. But it doesn't work, it deletes the data that have been first inserted with the snapshot.

    I use custom tracking tables , that are empty (Current data have been inserted without traking). I override GetChanges to enable Snapshot & DownloadOnly (Maybe i shouldn't, see code below)

    public override SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)  
            {  
     
                SyncContext __context;  
                System.Collections.Generic.Dictionary<string,IDbCommand>  __oldCommands = new Dictionary<string,IDbCommand>();  
                 
                foreach (SyncTableMetadata meta in groupMetadata.TablesMetadata)  
                {  
                    if (meta.SyncDirection == SyncDirection.Snapshot)  
                    {  
                        IDbCommand __oldCommand = this.SyncAdapters[meta.TableName].SelectIncrementalInsertsCommand;  
                        SqlCommand __selectAll = new SqlCommand();  
                        __selectAll.CommandType = CommandType.Text;  
                        __selectAll.CommandText = "SELECT * from " + meta.TableName;  
                        this.SyncAdapters[meta.TableName].SelectIncrementalInsertsCommand = __selectAll;  
                        __oldCommands.Add(meta.TableName,__oldCommand);  
                    }  
                }  
                __context = base.GetChanges(groupMetadata, syncSession);  
                foreach(string __key in __oldCommands.Keys)  
                {  
                        this.SyncAdapters[__key].SelectIncrementalInsertsCommand     = __oldCommands[__key];  
                }  
                return __context;  
            } 
     

    Please help,  Thanks!  eclore. (who apologize for his poor english, feel free to correct it too ^^).



    • Moved by Hengzhe Li Friday, April 22, 2011 5:32 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, February 18, 2009 4:35 PM

Answers

  •  can you try to set the tableCreationOption to "useExistingTableOrFail" after you change to download only ? in such way, the table will not be deleted and existing data will be kept.

    this assumes you added the tracking logic when you change to downloadonly sync direction.

    thanks
    Yunwen
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Sunday, February 22, 2009 6:14 AM
    Moderator

All replies

  •  can you try to set the tableCreationOption to "useExistingTableOrFail" after you change to download only ? in such way, the table will not be deleted and existing data will be kept.

    this assumes you added the tracking logic when you change to downloadonly sync direction.

    thanks
    Yunwen
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Sunday, February 22, 2009 6:14 AM
    Moderator
  • Hi Yunmy,

    Thank to you I saw that traking logic (two extra fields in sqlCE) was not created with Snapshot. And the dowloadOnly option recreate table, with those fields.

    Rather than adding client traking logic, i populated server tracking table and set all tableAdapter to downloadOnly.

    Thanks again.

    eclore.
    Monday, February 23, 2009 8:59 AM