Programming Common Peer-to-Peer Synchronization Tasks

The following topics in this section provide background information, procedural content, and complete code examples for common peer-to-peer synchronization tasks that you can perform by using Sync Services for ADO.NET 2.0.

In This Section

Example Applications in the How-to Topics

Each how-to topic contains a console application. This application is written in both C# and Visual Basic and demonstrates particular features of the API. Although it is quicker to show only code examples for a specific task or feature, it is much easier to understand how Sync Services works if you see a particular feature in a fairly complete context.

Each application contains the following classes, and also other classes that are relevant to the features that are being described:

  • Program This class sets up synchronization and calls methods from the Utility class. The Utility class handles all functionality that is not directly related to synchronization, such as holding connection string information and making changes to the server and client databases.

  • SampleSyncAgent This class is derived from SyncOrchestrator.

  • SampleSyncProvider This class includes a SetupSyncProvider method that creates: a DbSyncProvider object for each node that is being synchronized; and a DbSyncAdapter object for each table that is being synchronized.

The code for all the applications has been tested on Visual Studio 2008, SQL Server 2005 Service Pack 2, and SQL Server 2008.

To run each application

  1. Execute the "Custom Change Tracking for Collaborative Scenarios" Transact-SQL script in Setup Scripts for Sync Services How-to Topics. This script creates three databases, each with a set of tables and triggers, and a set of stored procedures. To delete and reinsert sample data, use the usp_ResetPeerData stored procedure.

  2. Copy the Utility class code from Utility Class for Sync Services How-to Topics. Paste this code into each application that you want to run, or create a DLL from the code and reference that DLL from each application.

  3. Add references to the following DLLs:

    • Microsoft.Synchronization.dll

    • Microsoft.Synchronization.Data.dll

See Also

Concepts

Collaboration Scenarios (Sync Services)