Delen via


Synchronizing Other ADO.NET Compatible Databases

The topics in this section provide background information, procedural content, and complete code examples for common synchronization tasks that you can perform by using Sync Framework. The topics are designed to demonstrate how databases other than SQL Server can be synchronized by using Sync Framework. In this release, SQL Server is used in code examples, but the code can be used for other ADO.NET compatible databases, with some modifications to the SQL Server-specific objects (such as SqlConnection) and the SQL queries that are shown. For information about SQL Server synchronization (including SQL Server Express and SQL Server Compact), see How to: Configure and Execute Collaborative Synchronization (SQL Server).

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 Framework 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 databases involved in synchronization.

  • SampleSyncAgent This class is derived from SyncOrchestrator.

  • SampleSyncProvider This class includes methods that create: a DbSyncProvider object or a SqlCeSyncProvider object for each node that is being synchronized; and a DbSyncAdapter object for each table that is being synchronized by using DbSyncProvider.

The code for all the applications has been tested on Visual Studio 2008 and SQL Server 2008.

To run each application

  1. Execute the "Custom Change Tracking for Collaborative Scenarios" Transact-SQL script in Setup Scripts for Database Provider 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 Database Provider 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. The database connection strings in this class use localhost for the database name. Update the database name if necessary.

  3. Add references to the following DLLs:

    • Microsoft.Synchronization.dll

    • Microsoft.Synchronization.Data.dll

    • Microsoft.Synchronization.Data.SqlServerCe.dll and System.Data.SqlServerCe.dll (not required for all examples)

See Also

Concepts

Architecture and Classes for Collaborative Synchronization
Collaboration Scenarios
How to: Configure and Execute Collaborative Synchronization (SQL Server)