Aracılığıyla paylaş


TransPublication.ValidatePublication Yöntemi

Satır içi yayın doğrulama için tüm abonelikleri başlatır.

Ad Alanı:  Microsoft.SqlServer.Replication
Derleme:  Microsoft.SqlServer.Rmo (Microsoft.SqlServer.Rmo içinde.dll)

Sözdizimi

'Bildirim
Public Sub ValidatePublication ( _
    validationOption As ValidationOption, _
    validationMethod As ValidationMethod, _
    shutdownAgent As Boolean _
)
'Kullanım
Dim instance As TransPublication
Dim validationOption As ValidationOption
Dim validationMethod As ValidationMethod
Dim shutdownAgent As Boolean

instance.ValidatePublication(validationOption, _
    validationMethod, shutdownAgent)
public void ValidatePublication(
    ValidationOption validationOption,
    ValidationMethod validationMethod,
    bool shutdownAgent
)
public:
void ValidatePublication(
    ValidationOption validationOption, 
    ValidationMethod validationMethod, 
    bool shutdownAgent
)
member ValidatePublication : 
        validationOption:ValidationOption * 
        validationMethod:ValidationMethod * 
        shutdownAgent:bool -> unit 
public function ValidatePublication(
    validationOption : ValidationOption, 
    validationMethod : ValidationMethod, 
    shutdownAgent : boolean
)

Parametreler

  • shutdownAgent
    Tür: System.Boolean
    A Boolean değer. Doğru , Dağıtım Aracısı kapatma kapalı hemen sonra doğrulama. Yanlış , Dağıtım Aracısı çalışmaya devam eder.

Açıklamalar

Doğrulama sonucunu çoğaltma İzleyicisi'ni kullanarak görüntülerse Aracısı geçmiş yazılır.Daha fazla bilgi için, bkz. Çoğaltma çoğaltma İzleyicisi ile izleme.

ValidatePublication yöntem yalnızca adlı üyeleri tarafından sysadmin sabit sunucu rolü yayımcı veya üyeleri tarafından db_owner sabit veritabanı rolü yayın veritabanı.

Arama ValidatePublication yürütmek için eşdeğer olduğu sp_publication_validation.

ValidatePublication yöntem için kullanıma hazır örnekleri SQL Server 2000 ve SQL Server 2005.

Bu ad, sınıf veya üye yalnızca desteklenen sürüm 2.0.net Framework.

Örnekler

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

            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 = "AdventureWorks2008R2"

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