I'm trying to synchronize two databases in SQL Server 2008 by using C#.
I followed this article below but I got some problems.
http://msdn.microsoft.com/en-us/library/ff928758(v=SQL.110).aspx[
^]
I can obtain it within two databases on a single computer.
But when I was trying to synchronize two databases which were on different computers, I got some errors at
"SqlSyncScopeProvisioning clientProvision = new SqlSyncScopeProvisioning(clientConn, scopeDesc);"
Could someone help me?
Thank you very much~~
This is my complete code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Synchronization;
using Microsoft.Synchronization.Data;
using Microsoft.Synchronization.Data.SqlServer;
namespace ProvisionClient
{
class Program
{
static void Main(string[] args)
{
SqlConnection clientConn = new SqlConnection(@"Data
Source=.\\SQLEXPRESS; Initial Catalog=SyncExpressDB;
Trusted_Connection=Yes");
SqlConnection serverConn = new SqlConnection("Data
Source=192.168.8.45\\SQLEXPRESS,1433;
Initial Catalog=SyncDB;
User ID=sa;Password=123");
DbSyncScopeDescription scopeDesc =
SqlSyncDescriptionBuilder.GetDescriptionForScope
("ProductsScope", serverConn);
error is here
====> SqlSyncScopeProvisioning clientProvision = new
SqlSyncScopeProvisioning(clientConn, scopeDesc);
clientProvision.SetCreateTableDefault
(DbSyncCreationOption.CreateOrUseExisting);
clientProvision.Apply();
}
}
}