0

我正在尝试在 SQL Server 2012 和 SQL Server Express 2012 之间设置复制。我已经通过 SSMS 设置了发布和订阅,并尝试通过 RMO 完成同步。

我已按照此处的答案进行操作,但我收到一条错误消息,指出我尝试同步的订阅不存在。我试过这个来检查订阅者的订阅列表,它是空的。

但我可以在 SSMS 中看到订阅。它就在那儿看着我。我一定错过了一些关于如何设置这些的东西。我已经删除并重新创建了发布和订阅。没运气。

更新:更改了示例代码以查找 TransPullSubscriptions。第二个链接中的代码现在可以正确打印订阅。

但是,实际运行同步的代码仍然看不到服务器上的订阅。

负载属性测试失败,但继续抛出错误:“SynchronizationAgent”只能在对象在服务器中呈现现有对象时使用。

更新:现在有更多代码!

    static void SynchronizeMergePullSubscriptionViaRMO()
    {
        // Define the server, publication, and database names. 
        string subscriberName = "testsubDBserver";
        string publisherName = "testpubDBserver";
        //string distributorName = "distribution";
        string publicationName = "test_sub";
        string subscriptionDbName = "Data";
        string publicationDbName = "Data";

        // Create a connection to the Subscriber. 
        ServerConnection conn = new ServerConnection(subscriberName);

        TransPullSubscription subscription;
        TransSynchronizationAgent agent;

        try
        {
            // Connect to the Subscriber. 
            conn.Connect();

            // Define the pull subscription. 
            subscription = new TransPullSubscription();
            subscription.ConnectionContext = conn;
            subscription.DatabaseName = subscriptionDbName;
            subscription.PublisherName = publisherName;
            subscription.PublicationDBName = publicationDbName;
            subscription.PublicationName = publicationName;

            // If the pull subscription exists, then start the synchronization. 
            if (!(subscription.LoadProperties()))
            {
                // Get the agent for the subscription. 
                agent = subscription.SynchronizationAgent;

                // Set the required properties that could not be returned 
                // from the MSsubscription_properties table. 
                //agent.PublisherSecurity = SecurityMode.Integrated;
                agent.DistributorSecurityMode = SecurityMode.Integrated;
                agent.Distributor = publisherName;

                // Enable verbose merge agent output to file. 
                agent.OutputVerboseLevel = 4;
                agent.Output = "D:\\logs\\mergeagent.log";

                // Synchronously start the Merge Agent for the subscription. 
                agent.Synchronize();
            }
4

1 回答 1

1

答案是即使在您完全确定所有内容都拼写正确之后,也要再次检查您的工作是否有拼写错误。testpubDBserver != testpubBDserver。

感谢布兰登的帮助。

于 2014-02-25T17:19:09.010 回答