Share via


How to: Configure a Local and Remote Database for Bidirectional Synchronization

The Configure Data Synchronization dialog box enables you to configure Microsoft Synchronization Services for ADO.NET for download scenarios only. This means that after you configure data synchronization by using the Configure Data Synchronization dialog box, calling Microsoft.Synchronization.Data.SyncAgent.Synchronize will only update the local database with changes found on the remote database. Changes made to the data on the local database will not be uploaded to the remote database.

The SyncTable.SyncDirection property controls how tables are synchronized between the local and remote databases. By default, the Configure Data Synchronization dialog box configures synchronization so that the value of the SyncTable.SyncDirection property is Microsoft.Synchronization.Data.SyncDirection.DownloadOnly or Microsoft.Synchronization.Data.SyncDirection.Snapshot. After you configure data synchronization, you can programmatically enable bidirectional synchronization by setting the SyncTable.SyncDirection property to Bidirectional.

Important

If you extend the designer-generated code to enable bidirectional synchronization, you also have to perform the following tasks:

Add code to handle synchronization conflicts.

Remove the server tracking columns from synchronization commands.

For detailed information, see Walkthrough: Extending the Local Database Cache to Support Bidirectional Synchronization.

To enable bidirectional synchronization between a local and remote database

  1. Configure your application for synchronization by adding a Local Database Cache item to the project and setting the appropriate configurations in the Configure Synchronization dialog box. For more information, see How to: Configure Data Synchronization in an Application.

  2. Add code that sets the SyncDirection property for each table on which bidirectional synchronization is desired.

  3. Add code to handle conflicts that may occur during synchronization.

  4. Remove the server tracking columns from the synchronization commands.

For detailed information, see Walkthrough: Extending the Local Database Cache to Support Bidirectional Synchronization.

See Also

Tasks

Walkthrough: Creating an Occasionally Connected Application

How to: Configure Data Synchronization in an Application

Concepts

Occasionally Connected Applications Overview

SQL Server Compact 3.5 and Visual Studio