Express Merge Relication Failing at runtime
- From: Ken Hundley <KenHundley@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Jul 2006 10:25:01 -0700
I am having a problem where when I step through the following code the
subscription correctly syncronizes, but whenever I run the program at full
speed I get the error "Unable to connect to distributor PubServer". I tried
adding sleeps and other pauses throughout this code but the error still
occured. I am in kind of a time crunch so ANY help with this solution is
GREATLY appreciated. Also, in the situation that I am in I have to use SQL
Authentication.
Thanks
--------------------
' Define the server, publication, and database names.
Dim subscriberName As String = "DevComp\SQLExpress"
Dim publisherName As String = "PubServer"
Dim publicationName As String = "TestDB"
Dim subscriptionDbName As String = "TestDB"
Dim publicationDbName As String = "TestDB"
' Create a connection to the Subscriber.
Dim conn As ServerConnection = New ServerConnection(subscriberName)
Dim subscription As MergePullSubscription
Try
' Connect to the Subscriber.
conn.Connect()
' Define the pull subscription.
subscription = New MergePullSubscription()
subscription.ConnectionContext = conn
subscription.DatabaseName = subscriptionDbName
subscription.PublisherName = publisherName
subscription.PublicationDBName = publicationDbName
subscription.PublicationName = publicationName
subscription.DistributorSecurity.WindowsAuthentication = False
subscription.DistributorSecurity.SqlStandardLogin = "TestName"
subscription.DistributorSecurity.SqlStandardPassword = "TestPass"
subscription.DistributorSecurity.Update()
subscription.PublisherSecurity.SecurityMode =
ReplicationSecurityMode.SqlStandard
subscription.PublisherSecurity.SqlStandardLogin = "TestName"
subscription.PublisherSecurity.SqlStandardPassword = "TestPass"
subscription.PublisherSecurity.Update()
' If the pull subscription exists, then start the synchronization.
If subscription.LoadProperties() Then
' Check that we have enough metadata to start the agent.
If Not subscription.PublisherSecurity Is Nothing Or
subscription.DistributorSecurity Is Nothing Then
' Output agent messages to the console.
subscription.SynchronizationAgent.OutputVerboseLevel = 1
subscription.SynchronizationAgent.Output = ""
' Synchronously start the Merge Agent for the
subscription.
subscription.SynchronizationAgent.Synchronize()
Else
Throw New ApplicationException("There is insufficent
metadata to " + _
"synchronize the subscription. Recreate the
subscription with " + _
"the agent job or supply the required agent properties
at run time.")
End If
Else
' Do something here if the pull subscription does not exist.
Throw New ApplicationException(String.Format( _
"A subscription to '{0}' does not exist on {1}", _
publicationName, subscriberName))
End If
Catch ex As Exception
' Implement appropriate error handling here.
Throw New ApplicationException("The subscription could not be "
+ _
"synchronized. Verify that the subscription has " + _
"been defined correctly.", ex)
Finally
conn.Disconnect()
End Try
--------------------
.
- Prev by Date: Re: Log reader agent changes updates to deletes and inserts
- Next by Date: Re: How to test a custom conflict resolver procedure
- Previous by thread: Re: Log reader agent changes updates to deletes and inserts
- Next by thread: Re: LogShipping: Get a copy of the destination DB?
- Index(es):
Relevant Pages
|