다음을 통해 공유


MergePullSubscription.Reinitialize(Boolean) 메서드

정의

병합 끌어오기 구독을 다시 초기화하도록 표시합니다.

public:
 void Reinitialize(bool uploadFirst);
public void Reinitialize (bool uploadFirst);
member this.Reinitialize : bool -> unit
Public Sub Reinitialize (uploadFirst As Boolean)

매개 변수

uploadFirst
Boolean

스냅숏을 다시 적용하여 구독을 다시 초기화하기 전에 구독자에서 모든 변경 내용을 업로드할지 여부를 지정하는 Boolean 값입니다. true이면 스냅샷을 적용하기 전에 변경 내용이 업로드됩니다. false이면 변경 내용이 업로드되지 않습니다.

예제

// Define server, publication, and database names.
String subscriberName = subscriberInstance;
String publisherName = publisherInstance;
String publicationName = "AdvWorksSalesOrdersMerge";
String publicationDbName = "AdventureWorks2012";
String subscriptionDbName = "AdventureWorks2012Replica";

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

MergePullSubscription subscription;

try
{
    // Connect to the Subscriber.
    conn.Connect();

    // Define subscription properties.
    subscription = new MergePullSubscription();
    subscription.ConnectionContext = conn;
    subscription.DatabaseName = subscriptionDbName;
    subscription.PublisherName = publisherName;
    subscription.PublicationDBName = publicationDbName;
    subscription.PublicationName = publicationName;

    // If the pull subscription and the job exists, mark the subscription
    // for reinitialization after upload and start the agent job.
    if (subscription.LoadProperties() && subscription.AgentJobId != null)
    {
        subscription.Reinitialize(true);
        subscription.SynchronizeWithJob();
    }
    else
    {
        // Do something here if the subscription does not exist.
        throw new ApplicationException(String.Format(
            "A subscription to '{0}' does not exists on {1}",
            publicationName, subscriberName));
    }
}
catch (Exception ex)
{
    // Do appropriate error handling here.
    throw new ApplicationException("The subscription could not be synchronized.", ex);
}
finally
{
    conn.Disconnect();
}
' Define server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"
Dim subscriptionDbName As String = "AdventureWorks2012Replica"

' 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 subscription properties.
    subscription = New MergePullSubscription()
    subscription.ConnectionContext = conn
    subscription.DatabaseName = subscriptionDbName
    subscription.PublisherName = publisherName
    subscription.PublicationDBName = publicationDbName
    subscription.PublicationName = publicationName

    ' If the pull subscription and the job exists, mark the subscription
    ' for reinitialization after upload and start the agent job.
    If subscription.LoadProperties() And (Not subscription.AgentJobId Is Nothing) Then
        subscription.Reinitialize(True)
        subscription.SynchronizeWithJob()
    Else
        ' Do something here if the subscription does not exist.
        Throw New ApplicationException(String.Format( _
         "A subscription to '{0}' does not exists on {1}", _
         publicationName, subscriberName))
    End If
Catch ex As Exception
    ' Do appropriate error handling here.
    Throw New ApplicationException("The subscription could not be synchronized.", ex)
Finally
    conn.Disconnect()
End Try

설명

메서드를 호출한 후 동기화를 Reinitialize 시작하여 구독을 다시 초기화해야 합니다. 자세한 내용은 방법: 구독 다시 초기화(RMO 프로그래밍)를 참조하세요.

이 메서드는 Reinitialize 구독자에서 sysadmin 고정 서버 역할의 멤버 또는 구독 데이터베이스에서 db_owner 고정 데이터베이스 역할의 멤버만 호출할 수 있습니다.

호출 Reinitializesp_reinitmergepullsubscription 실행하는 것과 같습니다.

적용 대상