Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

Community Wiki

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.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

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

Navigation

Google Ads

RMO Load Publisher Properties

From Wiki

Jump to: navigation, search

Use this base method to build your own for loading publisher properties for Merge Replication using RMO. The example shows how you can return the Snapshot folder for the publisher.

  1. public void LoadPubProperties()
  2.         {
  3.             string publicationName = <publication name>;
  4.             string publisherName = <instance the publisher is located on>;
  5.             string publicationDbName = <publication database>;
  6.  
  7.             MergePublication publication;
  8.  
  9.             ServerConnection conn = new ServerConnection(publisherName);
  10.  
  11.             try
  12.             {
  13.                 conn.Connect();
  14.  
  15.                 publication = new MergePublication();
  16.                 publication.ConnectionContext = conn;
  17.                 publication.Name = publicationName;
  18.                 publication.DatabaseName = publicationDbName;
  19.  
  20.                 publication.CachePropertyChanges = true;
  21.                 if (publication.LoadProperties())
  22.                 {
  23.                     snapLoc = publication.BrowseSnapshotFolder().ToString();
  24.                 }
  25.                 else
  26.                 {
  27.                     throw new ApplicationException(String.Format(
  28.                         "Settings could not be retrieved for the publication. " +
  29.                         "Ensure that the publication {0} exists on {1}.",
  30.                         publicationName, publisherName));
  31.                 }
  32.             }
  33.             catch (Exception ex)
  34.             {
  35.                 throw new ApplicationException(
  36.                     "The publication property could not be changed.", ex);
  37.             }
  38.             finally
  39.             {
  40.                 conn.Disconnect();
  41.             }
  42.         }

--onpnt 01:12, 30 December 2010 (GMT)

810 Rating: 2.2/5 (39 votes cast)