all groups > sql server replication > august 2006 >
You're in the

sql server replication

group:

RMO executing Synchronize() method failure


Re: RMO executing Synchronize() method failure Hilary Cotter
8/10/2006 12:00:00 AM
sql server replication:
Sounds like something is wrong with your code. Here is some code which works
for me. Its vb, but not my choice, my client wanted it in vb. Let me know if
you want a csharp version.

Imports Microsoft.SqlServer.Replication

Imports Microsoft.SqlServer.Management.Smo

Imports Microsoft.SqlServer.Management.Common

Imports Microsoft.SqlServer.Server



Public Class Form1

'changes the below lines for your topology

'--------------------------------------------





Dim publicationName As String = "PublicationName"

Dim publisherName As String = "SERVER"

Dim publisherLogin As String = "Non_sa_account_in_the_pal"

Dim publisherPassword As String = "Password"

Dim publicationDbName As String = "PublicationDB"

Dim distributorLogin As String = "DBO_account_in_the_distributionDatabase"

Dim distributorPassword As String = "Password"

Dim distributorAddress As String = "10.10.10.10"

Dim internetTimeout As Integer = 3000

Dim subscriberLogin As String = "Non_sa_account_on_the_Subscriber"

Dim subscriberPassword As String = "Password"

Dim subscriberName As String = "SubscriberMachineName"

Dim subscriptionDbName As String = "AdventureWorksReplica"

Dim hostname As String = "SubscriberMachineName"

Dim subscriberSynchronizationAccount =
"WindowsNTAccountOnTheSubscriberShouldBeInTheLocalAdministratorsGroup"

Dim subscriberSynchronizationPassword = "Password"

Dim internetLogin As String = "BasicAuthenticationAccountOnWebServer"

Dim internetPassword As String = "password"

Dim OutputVerboseLevel As Integer = 3

Dim outputFile As String = "C:\replication.out"

Dim webSyncUrl As String =
"https://server.MyDomain.com/MyVirtualDirectory/replisapi.dll"

'--------------------------------





Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' The publication must support anonymous Subscribers, pull

' subscriptions, and Web synchronization.

' Define the Publisher, publication, and databases.



'Create the Subscriber connection.

Dim conn As ServerConnection = New ServerConnection(subscriberName)

' Create the objects that we need.

Dim subscription As MergePullSubscription

Try

' Connect to the Subscriber.

'conn.Connect()



' Define the pull subscription.

subscription = New MergePullSubscription()

subscription.ConnectionContext = conn

subscription.PublisherName = publisherName

subscription.PublicationName = publicationName

subscription.PublicationDBName = publicationDbName

subscription.DatabaseName = subscriptionDbName

subscription.HostName = hostname

' Specify an anonymous Subscriber type since we can't

' register at the Publisher with a direct connection.

subscription.SubscriberType = MergeSubscriberType.Anonymous

' Specify the Windows login credentials for the Merge Agent job.

subscription.SynchronizationAgentProcessSecurity.Login =
subscriberSynchronizationAccount

subscription.SynchronizationAgentProcessSecurity.Password =
subscriberSynchronizationPassword

' 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 = internetLogin

subscription.InternetPassword = internetPassword

' Ensure that we create a job for this subscription.

subscription.CreateSyncAgentByDefault = True

' Create the pull subscription at the Subscriber.

If subscription.IsExistingObject() = True Then

Synchronize.Visible = True

CreateSubscription.Visible = False

Else

Synchronize.Visible = False

CreateSubscription.Visible = True

End If

Catch ex As Exception

' Implement the appropriate error handling here.

MessageBox.Show(ex.InnerException.ToString())

Finally

conn.Disconnect()

End Try





End Sub

Private Sub CreateSubscription_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CreateSubscription.Click

' The publication must support anonymous Subscribers, pull

' subscriptions, and Web synchronization.

' Define the Publisher, publication, and databases.



'Create the Subscriber connection.

Dim conn As ServerConnection = New ServerConnection(subscriberName)

' Create the objects that we need.

Dim subscription As MergePullSubscription

Try

' Connect to the Subscriber.

'conn.Connect()



' Define the pull subscription.

subscription = New MergePullSubscription()

subscription.ConnectionContext = conn

subscription.PublisherName = publisherName

subscription.PublicationName = publicationName

subscription.PublicationDBName = publicationDbName

subscription.DatabaseName = subscriptionDbName

subscription.HostName = hostname

' Specify an anonymous Subscriber type since we can't

' register at the Publisher with a direct connection.

subscription.SubscriberType = MergeSubscriberType.Anonymous

' Specify the Windows login credentials for the Merge Agent job.

subscription.SynchronizationAgentProcessSecurity.Login =
subscriberSynchronizationAccount

subscription.SynchronizationAgentProcessSecurity.Password =
subscriberSynchronizationPassword

' 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 = internetLogin

subscription.InternetPassword = internetPassword

' Ensure that we create a job for this subscription.

subscription.CreateSyncAgentByDefault = True

' Create the pull subscription at the Subscriber.

subscription.Create()

Synchronize.Visible = True

Catch ex As Exception

' Implement the appropriate error handling here.

MessageBox.Show(ex.InnerException.ToString())

Finally

conn.Disconnect()

End Try



End Sub

Private Sub Synchronize_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Synchronize.Click



Dim mergeAgent As New MergeSynchronizationAgent

Synchronize.Visible = False

'AddHandler mergeAgent.Status, New MergeSynchronizationAgent(AddressOf
objSnapshot_status)

AddHandler mergeAgent.Status, New
Microsoft.SqlServer.Replication.AgentCore.StatusEventHandler(AddressOf
MergeStatus)

'/'/StatusEventHandler()

'AddHandler mergeAgent.Status, New StatusEventHandler(AddressOf
Merge_StatusEventHandler, AddressOf Percent)

mergeAgent.Publication = publicationName

mergeAgent.Publisher = publisherName

mergeAgent.PublisherDatabase = publicationDbName

RMO executing Synchronize() method failure Tomasz Krupa
8/10/2006 2:08:01 AM
Hello,
While executing Synchronize() method I've got a error:

"The subscription to publication 'XYZPublication' 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. "

My publicator is running on SQL Server 2005, subscriber on SQL Server
Express, publication type is Merge Pull Publication. Server and Client are
not in the same domain - they are connected through Web synchronization.
I''ve tried to add new Alias and entry in Host file but it didn't help.
Thank's for any sugestions.
Re: RMO executing Synchronize() method failure Tomasz Krupa
8/10/2006 7:29:01 AM
HI
thanks for Your code but I still have a problem with Synchronize() method.
Now I've got error "A connection with the server could not be established". I
think I do something wrong with names, here`s my configuration section block
with descritpions:

Dim publicationName As String = "FakturaServerPublication"
Dim publisherName As String = "62.xxx.xxx.xxx,1513\SQL2005"
// it`s ipAdress,port\SqlServer publisherName
Dim publisherLogin As String = "Fs"
//sql Server publisher login
Dim publisherPassword As String = "Fs"
//sql server publisher password
Dim publicationDbName As String = "FakturaServer"
Dim distributorLogin As String = "Fs"
//sql server distributor login
Dim distributorPassword As String = "Fs"
//sql server distributor password
Dim distributorAddress As String = "62.xxx.xxx.xxx,1513\Sql2005"
Dim internetTimeout As Integer = 3000
Dim subscriberLogin As String = "Fs"
//sql Server subscriber login
Dim subscriberPassword As String = "Fs"
//sql Server subscriber password
Dim subscriberName As String = "MANI\SQLEXPRESS"
Dim subscriptionDbName As String = "FakturaServer"
Dim hostname As String = "MANI"
// MANI is my subscriber machine name
Dim subscriberSynchronizationAccount = "MANI\Marcin"
// Marcin user
Dim subscriberSynchronizationPassword = "Marcin"
// Marcin user password
Dim internetLogin As String = "sql"
//windows account on server login
Dim internetPassword As String = "sqlPassword"
//windows account on server password
Dim OutputVerboseLevel As Integer = 3
Dim outputFile As String = "C:\replication.out"
Dim webSyncUrl As String = "https://62.xxx.xxx.xxx/migration/replisapi.dll"


I suppose it could be ssl configuration in IIS problem, what do You think ?

[quoted text, click to view]
Re: RMO executing Synchronize() method failure Hilary Cotter
8/10/2006 11:35:03 AM
Use

mergeAgent.Publisher = publisherName 'what you get if you issue a select
@@servername on your publisher

mergeAgent.DistributorNetwork = NetworkType.TcpIPSockets

mergeAgent.DistributorAddress = "62.xxx.xxx.xxx,1513\SQL2005" ' note xxx's
are not valid ip addresses it has to be numbers;) and further note that I am
not sure if its a comma or a semi-colon or if you specify your instance name
here. You'll have to check that out on your end.



--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.


This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.

Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com



[quoted text, click to view]
AddThis Social Bookmark Button