我有一个SQL 2008 R2服务器。 我已经创建了一个使用向导的出版物,似乎没问题。 “系统数据库”部分有一个“分布”数据库,其中没有太多内容。 (不知道这是否已经存在,或者“发布向导”是否已经创建了它。) 我已经安装了网络同步并且可以通过IIS7和自签名证书访问relisapi.dll。SQL Server 2008通过网络同步复制到SQL Express 2005
我的ASP.NET网站安装程序安装SQL Express 2005. 我写了一个小网站来测试订阅和初始同步的创建。 我不会“创建初始”数据库,因为我假设第一个同步将从服务器拉下所有内容。
以下几行代码似乎可行,因为预订是在SQL 2008服务器中的SQL Express &中创建的。
' Define the pull subscription.
subscription = New MergePullSubscription()
subscription.ConnectionContext = subscriberConn
subscription.PublisherName = publisherName
subscription.PublicationName = publicationName
subscription.PublicationDBName = publicationDbName
subscription.DatabaseName = subscriptionDbName
subscription.HostName = hostname
subscription.CreateSyncAgentByDefault = True
' Specify the Windows login credentials for the Merge Agent job.
subscription.SynchronizationAgentProcessSecurity.Login = winLogin
subscription.SynchronizationAgentProcessSecurity.Password = winPassword
' Enable Web synchronization.
subscription.UseWebSynchronization = True
subscription.InternetUrl = webSyncUrl
' Specify the same Windows credentials to use when connecting to the
' Web server using HTTPS Basic Authentication.
subscription.InternetSecurityMode = AuthenticationMethod.BasicAuthentication
subscription.InternetLogin = winLogin
subscription.InternetPassword = winPassword
If Not subscription.LoadProperties() Then
' Create the pull subscription at the Subscriber.
subscription.Create()
然后我运行这段代码:
If Not subscription.PublisherSecurity Is Nothing Or _
subscription.DistributorSecurity Is Nothing Then
'0: Only error messages are logged.
'1: All progress report messages are logged.
'2: All progress report messages and error messages are logged.
subscription.SynchronizationAgent.OutputVerboseLevel = 2
subscription.SynchronizationAgent.Output = "c:\createmerge.txt"
' Synchronously start the Merge Agent for the subscription.
subscription.SynchronizationAgent.Synchronize()
但syncronize引发错误:
The subscription to publication 'My publication' could not be verified. Ensure that all Merge Agent command line parameters are specified correctly and that the subscription is correctly configured. If the Publisher no longer has information about this subscription, drop and recreate the subscription.
在服务器上,使用 “复制监视器” 它显示我的订阅作为“单元化”。
我认为一个问题是,我的subscription.HostName是错误的。 MSDN上的微软例子说
"adventure-works\garrett1"
但冒险的作品是否是服务器,实例或数据库,谁是garrett1(登录或别的东西),目前尚不清楚。那实际上应该是什么呢?
因为我对复制一无所知,而且我一直在关注MSDN和一些书籍,所以我会认真考虑下一步该怎么做。
对不起,这么久了!