Sync database except deleted records RRS feed

  • Question

  • I’ve been going through a lot of documentation the last few days. And I know it must be possible, but still haven’t found how. So I hope that someone can help me.

    I want to synchronize a SQL Server database with another SQL Server database but only add and edit the records. For example, if I remove record X from database A and synchronize, database B will still have record X, but all other created and modified records will be synchronized.

    I understand I’ll have to set the direction on only download/upload. And that it’s not possible to use change tracking of SQL Server for this situation. But how do I set this manually?! (I don’t mind if I have to use the 4.0 CTP version of the Sync Framework).

    Tuesday, November 16, 2010 3:54 PM

All replies

  • if you want to manipulate local changes before they are uploaded and applied to the remote provider, you can subscribe to the ChangesSelected event on the local provider and go thru the change dataset and manipulate it.

    here's a sample (just chk yhe syntax if i did it right as i only copied and modified my other sample)

    void LocalDataCache1ServerSyncProvider_ChangesSelected(object sender, Microsoft.Synchronization.Data.ChangesSelectedEventArgs e)
                //let's check if we're synching the table we're interested
                if (e.Context.DataSet.Tables.Contains("WorkOrders"))
                    var dataTable = e.Context.DataSet.Tables["WorkOrders"];
                    for (int j = 0; j < dataTable.Rows.Count; j++)
                        DataRow row = dataTable.Rows[j];

                        // we're only interested in deletes
                        if (row.RowState == DataRowState.Deleted)
                                // let's remove the row so it doesnt get sent and applied at the remote side


    • Proposed as answer by Jandeep Friday, November 19, 2010 11:19 PM
    Wednesday, November 17, 2010 9:24 AM