MergeSynchronizationAgent.HostName 속성

Gets or sets the value used by the Merge Agent when it evaluates a parameterized filter that uses the HOST_NAME function.

네임스페이스:  Microsoft.SqlServer.Replication
어셈블리:  Microsoft.SqlServer.Replication(Microsoft.SqlServer.Replication.dll)

구문

‘선언
Public Overridable Property HostName As String 
    Get 
    Set
‘사용 방법
Dim instance As MergeSynchronizationAgent 
Dim value As String 

value = instance.HostName

instance.HostName = value
public virtual string HostName { get; set; }
public:
virtual property String^ HostName {
    String^ get ();
    void set (String^ value);
}
abstract HostName : string with get, set 
override HostName : string with get, set
function get HostName () : String 
function set HostName (value : String)

속성 값

유형: System.String
The value used by the Merge Agent.

구현

IMergeSynchronizationAgent.HostName

주의

Use the HostName property to have the Merge Agent override the value typically returned by the HOST_NAME function when this function is used to define a parameterized filter. For example, if you use the parameterized filter clause LoginID = HOST_NAME() to define horizontal filtering for an article, and if you set the HostName property to "adventure-works\david8" before calling the Synchronize method, the Merge Agent will synchronize data for the partition defined by "adventure-works\david8".

The case of the HostName property is ignored only when both the Publisher and the publication database are configured as case-insensitive.

         // Define the server, publication, and database names.
            string subscriberName = subscriberInstance;
            string publisherName = publisherInstance;
            string distributorName = distributorInstance;
            string publicationName = "AdvWorksSalesOrdersMerge";
            string subscriptionDbName = "AdventureWorks2012Replica";
            string publicationDbName = "AdventureWorks2012";
            string hostname = @"adventure-works\garrett1";
            string webSyncUrl = "https://" + publisherInstance + "/SalesOrders/replisapi.dll";

            // Create a connection to the Subscriber.
            ServerConnection conn = new ServerConnection(subscriberName);

            MergePullSubscription subscription;
            MergeSynchronizationAgent agent;

            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;

                // If the pull subscription exists, then start the synchronization.
                if (subscription.LoadProperties())
                {
                    // Get the agent for the subscription.
                    agent = subscription.SynchronizationAgent;

                    // Check that we have enough metadata to start the agent.
                    if (agent.PublisherSecurityMode == null)
                    {
                        // Set the required properties that could not be returned
                        // from the MSsubscription_properties table. 
                        agent.PublisherSecurityMode = SecurityMode.Integrated;
                        agent.DistributorSecurityMode = SecurityMode.Integrated;
                        agent.Distributor = publisherName;
                        agent.HostName = hostname;

                        // Set optional Web synchronization properties.
                        agent.UseWebSynchronization = true;
                        agent.InternetUrl = webSyncUrl;
                        agent.InternetSecurityMode = SecurityMode.Standard;
                        agent.InternetLogin = winLogin;
                        agent.InternetPassword = winPassword;
                    }
                    // Enable agent output to the console.
                    agent.OutputVerboseLevel = 1;
                    agent.Output = "";

                    // Synchronously start the Merge Agent for the subscription.
                    agent.Synchronize();
                }
                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));
                }
            }
            catch (Exception ex)
            {
                // 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();
            }
' Define the server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"
Dim hostname As String = "adventure-works\garrett1"
Dim webSyncUrl As String = "https://" + publisherInstance + "/SalesOrders/replisapi.dll"

' Create a connection to the Subscriber.
Dim conn As ServerConnection = New ServerConnection(subscriberName)

Dim subscription As MergePullSubscription
Dim agent As MergeSynchronizationAgent

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

    ' If the pull subscription exists, then start the synchronization.
    If subscription.LoadProperties() Then
        ' Get the agent for the subscription.
        agent = subscription.SynchronizationAgent

        ' Check that we have enough metadata to start the agent.
        If agent.PublisherSecurityMode = Nothing Then
            ' Set the required properties that could not be returned
            ' from the MSsubscription_properties table. 
            agent.PublisherSecurityMode = SecurityMode.Integrated
            agent.Distributor = publisherInstance
            agent.DistributorSecurityMode = SecurityMode.Integrated
            agent.HostName = hostname

            ' Set optional Web synchronization properties.
            agent.UseWebSynchronization = True
            agent.InternetUrl = webSyncUrl
            agent.InternetSecurityMode = SecurityMode.Standard
            agent.InternetLogin = winLogin
            agent.InternetPassword = winPassword
        End If

        ' Enable agent logging to the console.
        agent.OutputVerboseLevel = 1
        agent.Output = ""

        ' Synchronously start the Merge Agent for the subscription.
        agent.Synchronize()
    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

참고 항목

참조

MergeSynchronizationAgent 클래스

Microsoft.SqlServer.Replication 네임스페이스

관련 자료

방법: 끌어오기 구독 동기화(RMO Programming)

방법: 밀어넣기 구독 동기화(Replication Programming)