Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
RMO Synchronize subscription
From Wiki
Use this base method to start synchronizing replication from publisher to subscriber. This is extremely useful when the subscriber is SQLExpress or other sources that do not utilize the SQL Agent.
- string publicationName = <publication name>;
- string publisherName = <publication instance>;
- string subscriberName = <subscription instance>;
- string subscriptionDbName = <subscription database name>;
- string publicationDbName = <publication database;
- ServerConnection conn = new ServerConnection(subscriberName);
- ServerConnection publisherConn = new ServerConnection(publisherName);
- MergePullSubscription subscription;
- try
- {
- conn.Connect();
- publisherConn.Connect();
- subscription = new MergePullSubscription();
- subscription.ConnectionContext = conn;
- subscription.PublisherSecurity.SecurityMode = ReplicationSecurityMode.SqlStandard;
- subscription.DistributorSecurity.WindowsAuthentication = false;
- subscription.DatabaseName = subscriptionDbName;
- subscription.PublisherName = publisherName;
- subscription.PublicationDBName = publicationDbName;
- subscription.PublicationName = publicationName;
- if (subscription.LoadProperties())
- {
- if (subscription.PublisherSecurity != null || subscription.DistributorSecurity != null)
- {
- 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.");
- }
- }
- else
- {
- throw new ApplicationException(String.Format(
- "A subscription to '{0}' does not exist on {1}",
- publicationName, subscriberName));
- }
- }
- catch (Exception ex)
- {
- throw new ApplicationException("The subscription could not be " +
- "synchronized. Verify that the subscription has " +
- "been defined correctly.", ex);
- }
- finally
- {
- conn.Disconnect();
- }
- }
--onpnt 01:23, 30 December 2010 (GMT)



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.