通过RMO的SQL Server Express 2012 Pull Sync看不到订阅

时间:2014-02-24 17:34:56

标签: sql-server-2012 transactional-replication rmo

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

我已经按照here的答案,我收到一条错误消息,说我正在尝试同步的订阅不存在。我尝试this检查订阅者的订阅列表,它是空的。

但我可以在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();
            }

1 个答案:

答案 0 :(得分:1)

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

感谢布兰登的帮助。