TransPublication.ValidatePublication Method

すべてのサブスクリプションのインライン パブリケーション検証を呼び出します。

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

構文

'宣言
Public Sub ValidatePublication ( _
    validationOption As ValidationOption, _
    validationMethod As ValidationMethod, _
    shutdownAgent As Boolean _
)
public void ValidatePublication (
    ValidationOption validationOption,
    ValidationMethod validationMethod,
    bool shutdownAgent
)
public:
void ValidatePublication (
    ValidationOption validationOption, 
    ValidationMethod validationMethod, 
    bool shutdownAgent
)
public void ValidatePublication (
    ValidationOption validationOption, 
    ValidationMethod validationMethod, 
    boolean shutdownAgent
)
public function ValidatePublication (
    validationOption : ValidationOption, 
    validationMethod : ValidationMethod, 
    shutdownAgent : boolean
)

パラメータ

  • validationOption
    実行されている検証の種類を指定する ValidationOption オブジェクトの値です。
  • validationMethod
    行数検証のオプションを指定する ValidationMethod オブジェクトの値です。
  • shutdownAgent
    Boolean 値です。true の場合、検証後すぐにディストリビューション エージェントがシャットダウンします。false の場合、ディストリビューション エージェントはそのまま実行されます。

解説

検証の結果はエージェントの履歴に書き込まれ、レプリケーション モニタを使用して表示されます。詳細については、「レプリケーション モニタを使用したレプリケーションの監視」を参照してください。

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

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

ValidatePublication メソッドは、SQL Server 2000 および SQL Server 2005 のインスタンスに使用できます。

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

使用例

// Define the server, database, and publication names
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks";

TransPublication publication;

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

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

    // Set the required properties for the publication.
    publication = new TransPublication();
    publication.ConnectionContext = conn;
    publication.Name = publicationName;
    publication.DatabaseName = publicationDbName;

    // If we can't get the properties for this publication, 
    // throw an application exception.
    if (publication.LoadProperties())
    {
        // Initiate validataion for all subscriptions to this publication.
        publication.ValidatePublication(ValidationOption.RowCountOnly,
            ValidationMethod.ConditionalFast, false);

        // If not already running, start the Distribution Agent at each 
        // Subscriber to synchronize and validate the subscriptions.
    }
    else
    {
        throw new ApplicationException(String.Format(
            "Settings could not be retrieved for the publication. " +
            "Ensure that the publication {0} exists on {1}.",
            publicationName, publisherName));
    }
}
catch (Exception ex)
{
    // Do error handling here.
    throw new ApplicationException(
        "Subscription validation could not be initiated.", ex);
}
finally
{
    conn.Disconnect();
}
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks"

Dim publication As TransPublication

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

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

    ' Set the required properties for the publication.
    publication = New TransPublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' If we can't get the properties for this publication, 
    ' throw an application exception.
    If publication.LoadProperties() Then

        ' Initiate validataion for all subscriptions to this publication.
        publication.ValidatePublication(ValidationOption.RowCountOnly, _
         ValidationMethod.ConditionalFast, False)

        ' If not already running, start the Distribution Agent at each 
        ' Subscriber to synchronize and validate the subscriptions.
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication. " + _
         "Ensure that the publication {0} exists on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException( _
     "Subscription validation could not be initiated.", ex)
Finally
    conn.Disconnect()
End Try

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

TransPublication Class
TransPublication Members
Microsoft.SqlServer.Replication Namespace