Reinitialize メソッド

プル サブスクリプションに再初期化のマークを付けます。

名前空間:  Microsoft.SqlServer.Replication
アセンブリ:  Microsoft.SqlServer.Rmo (Microsoft.SqlServer.Rmo.dll)

構文

'宣言
Public Sub Reinitialize
'使用
Dim instance As TransPullSubscription

instance.Reinitialize()
public void Reinitialize()
public:
void Reinitialize()
member Reinitialize : unit -> unit 
public function Reinitialize()

説明

Reinitialize メソッドを呼び出した後に、サブスクリプションを再初期化するために、同期を開始する必要があります。詳細については、「サブスクリプションを再初期化する方法 (RMO プログラミング)」を参照してください。

Reinitialize メソッドを呼び出すことができるのは、サブスクライバ側の固定サーバー ロール sysadmin のメンバ、またはサブスクリプション データベースの固定データベース ロール db_owner のメンバだけです。

Reinitialize を呼び出すと、sp_reinitpullsubscription を実行したのと同じことになります。

Reinitialize メソッドは、SQL Server 2000 と Microsoft SQL Server 2005 で使用できます。

この名前空間、クラス、またはメンバは、.NET Framework 2.0 でのみサポートされています。

使用例

         // Define server, publication, and database names.
            String subscriberName = subscriberInstance;
            String publisherName = publisherInstance;
            String publicationName = "AdvWorksProductTran";
            String publicationDbName = "AdventureWorks2008R2";
            String subscriptionDbName = "AdventureWorks2008R2Replica";

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

            TransPullSubscription subscription;

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

                // Define subscription properties.
                subscription = new TransPullSubscription();
                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 and start the agent job.
                if (subscription.LoadProperties() && subscription.AgentJobId != null)
                {
                    subscription.Reinitialize();
                    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 reinitialized.", ex);
            }
            finally
            {
                conn.Disconnect();
            }
' Define server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2008R2"
Dim subscriptionDbName As String = "AdventureWorks2008R2Replica"

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

Dim subscription As TransPullSubscription

Try
    ' Connect to the Subscriber.
    conn.Connect()

    ' Define subscription properties.
    subscription = New TransPullSubscription()
    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 and start the agent job.
    If subscription.LoadProperties() And (Not subscription.AgentJobId Is Nothing) Then
        subscription.Reinitialize()
        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 reinitialized.", ex)
Finally
    conn.Disconnect()
End Try