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
How to: Provision a Server Database for Collaborative Synchronization (Non-SQL Server)
How to: Configure and Execute Collaborative Synchronization (Non-SQL Server)
How to: Use Session Variables for Collaborative Synchronization (Non-SQL Server)
How to: Clean Up Metadata for Collaborative Synchronization (Non-SQL Server)
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:
ProgramThis class sets up synchronization and calls methods from the
Utilityclass 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.
SampleSyncAgentThis class is derived from SyncOrchestrator.
SampleSyncProviderThis 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
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
Utilityclass 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
localhostfor the database name. Update the database name if necessary.
Add references to the following DLLs:
Microsoft.Synchronization.Data.SqlServerCe.dll and System.Data.SqlServerCe.dll (not required for all examples)
Architecture and Classes for Collaborative Synchronization
How to: Configure and Execute Collaborative Synchronization (SQL Server)