Express Merge Relication Failing at runtime

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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
--------------------
.



Relevant Pages

  • Re: 2 machines..how hard could it be
    ... Dim publicationName As String = "PublicationName" ... Dim subscription As MergePullSubscription ...
    (microsoft.public.sqlserver.replication)
  • Re: RMO executing Synchronize() method failure
    ... Dim publicationName As String = "PublicationName" ... Dim publisherName As String = "SERVER" ... ' Define the Publisher, publication, and databases. ... Dim subscription As MergePullSubscription ...
    (microsoft.public.sqlserver.replication)
  • "This database is not enabled for publication" error in RMO
    ... I have a problem doing RMO programing to start a push subscription. ... Dim subscriberName As String = "Mike5150" ... at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) ...
    (microsoft.public.sqlserver.replication)
  • Re: e mail
    ... Somehow this mouth breather managed to subscribe ... But he was too dim to figure how to unsubscribe from a list he subscribed ... I have dropped him from the list, and I am tightening up the subscription ...
    (alt.food.barbecue)
  • Re: Initial Snapshot not available for Transactional Replication
    ... resynchronizing the subscription this has any effect on permissions. ... Looking for a SQL Server replication book? ... Agent" option is alive. ... Also, the status of the snapshot agent says "Suceeded", and the Last ...
    (microsoft.public.sqlserver.replication)