共用方式為


ValidationOption 列舉

Enumerates the types of data validation supported by replication.

命名空間:  Microsoft.SqlServer.Replication
組件:  Microsoft.SqlServer.Rmo (在 Microsoft.SqlServer.Rmo.dll 中)

語法

'宣告
Public Enumeration ValidationOption
'用途
Dim instance As ValidationOption
public enum ValidationOption
public enum class ValidationOption
type ValidationOption
public enum ValidationOption

成員

成員名稱 說明
Checksum70 Performs a checksum operation. This option is only supported for Microsoft SQL Server 7.0 Subscribers.
RowCountOnly Performs a rowcount operation.
Checksum80 Performs a binary checksum operation.

範例

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

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

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

請參閱

參考

Microsoft.SqlServer.Replication 命名空間

MergePublication

TransPublication

其他資源

驗證複寫的資料

如何:驗證訂閱者端的資料 (RMO 程式設計)