Hi all,
I am trying to do a merge replication between a SQL Server 2k database and MSDE. And I would like to have the changes that is made on both sides merged, say, the changes made on the msde will be applied to the server and vice versa.
I have set the 'SubscriptionType' to 'SQLMERGXLib.SUBSCRIPTION_TYPE.ANONYMOUS'. when I run the app, it seems that it is only doing a pull replication, which means that it only applies the changes on the server side to the client MSDE, but not bidirectionally.
This is different from the merge replication happening between SQL Server and SQL CE, in the case of which, you can call SqlCeReplication.syncronization() to merge the changes on both sides.
I am a bit confused by these two fashions of replication. Does anyone know how to do a 'bidirectional' merge replication between SQL server and MSDE?
Here is my code:
try
{
string strPublisher, strDistributor, strSubscriber, strPublisherDatabase, strSubscriberDatabase, strPublication;
strPublisher = "Pluto"; // name of your publisher
strDistributor = "Pluto"; // name of your distributor
strSubscriber = Environment.MachineName+"\\MSDE"; // name of your subscriber
strPublication = "TestConf";
strPublisherDatabase = "TestConf";
strSubscriberDatabase = "TestConf";
SQLMergeClass oMerge = new SQLMergeClass();
//Set up the Publisher.
oMerge.Publisher = strPublisher;
oMerge.PublisherSecurityMode = SQLMERGXLib.SECURITY_TYPE.NT_AUTHENTICATION;
oMerge.PublisherDatabase = strPublisherDatabase;
oMerge.Publication = strPublication;
//Set up the Distributor.
oMerge.Distributor = strDistributor;
oMerge.DistributorSecurityMode = SQLMERGXLib.SECURITY_TYPE.NT_AUTHENTICATION;
//Set up the Subscriber.
oMerge.Subscriber = strSubscriber;
oMerge.SubscriberDatasourceType = 0;
oMerge.SubscriberDatabase = strSubscriberDatabase;
oMerge.SubscriberSecurityMode = SQLMERGXLib.SECURITY_TYPE.NT_AUTHENTICATION;
//Set up the subscription.
oMerge.SubscriptionType = SQLMERGXLib.SUBSCRIPTION_TYPE.ANONYMOUS;
oMerge.SynchronizationType = SQLMERGXLib.SYNCHRONIZATION_TYPE.AUTOMATIC;
// oMerge.SubscriptionName = "PullMergeSubscription";
//Create the database and subscription.
oMerge.AddSubscription(SQLMERGXLib.DBADDOPTION.CREATE_DATABASE, SQLMERGXLib.SUBSCRIPTION_HOST.NONE);
//Synchronize the subscription.
Console.WriteLine("Starting synchronization...");
oMerge.Initialize();
oMerge.Run();
oMerge.Terminate();
Console.WriteLine("Synchronization completed.");
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
Console.WriteLine(e.Message);
}
Thanks in adv.
Cheers,
Justin
Bi-directional replication is the default, i don't see anything in your code that would prevent that. It shouldn't matter if the subscription is anonymous or local, that should have no bearing on whether changes get uploaded/downloaded or not.
Are you absolutely sure changes were made at the subscriber db?
No comments:
Post a Comment