次の方法で共有


AgentCheckupInterval プロパティ

ディストリビューション エージェントが照合を行う間隔を取得します。値の設定も可能です。

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

構文

'宣言
Public Property AgentCheckupInterval As Integer
    Get
    Set
'使用
Dim instance As ReplicationServer
Dim value As Integer

value = instance.AgentCheckupInterval

instance.AgentCheckupInterval = value
public int AgentCheckupInterval { get; set; }
public:
property int AgentCheckupInterval {
    int get ();
    void set (int value);
}
member AgentCheckupInterval : int with get, set
function get AgentCheckupInterval () : int
function set AgentCheckupInterval (value : int)

プロパティ値

型: System. . :: . .Int32
ディストリビューション エージェントが照合を行う間隔を指定する Int32 値です。

例外

例外 条件
ApplicationException

サーバーがディストリビュータではない場合。

説明

AgentCheckupInterval を使用する前に現在のサーバーがディストリビュータかどうかを調べるには、IsDistributor を使用します。

このプロパティは、SQL Server 7.0、SQL Server 2000、および SQL Server 2005 で使用できます。

AgentCheckupInterval プロパティを取得できるのは、固定データベース ロール public のメンバです。

AgentCheckupInterval プロパティを設定できるのは、固定サーバー ロール sysadmin のメンバだけです。AgentCheckupInterval プロパティを取得すると、sp_helpdistributor_properties (Transact-SQL) ストアド プロシージャを実行したのと同じことになります。

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

使用例

          // Set the Distributor and distribution database names.
            string distributionDbName = "distribution";
            string distributorName = publisherInstance;

            ReplicationServer distributor;
            DistributionDatabase distributionDb;

            // Create a connection to the Distributor using Windows Authentication.
            ServerConnection conn = new ServerConnection(distributorName);

            try
            {
                // Open the connection. 
                conn.Connect();

                distributor = new ReplicationServer(conn);

                // Load Distributor properties, if it is installed.
                if (distributor.LoadProperties())
                {
                    // Password supplied at runtime.
                    distributor.ChangeDistributorPassword(password);
                    distributor.AgentCheckupInterval = 5;

                    // Save changes to the Distributor properties.
                    distributor.CommitPropertyChanges();
                }
                else
                {
                    throw new ApplicationException(
                        String.Format("{0} is not a Distributor.", publisherInstance));
                }

                // Create an object for the distribution database 
                // using the open Distributor connection.
                distributionDb = new DistributionDatabase(distributionDbName, conn);

                // Change distribution database properties.
                if (distributionDb.LoadProperties())
                {
                    // Change maximum retention period to 48 hours and history retention 
                    // period to 24 hours.
                    distributionDb.MaxDistributionRetention = 48;
                    distributionDb.HistoryRetention = 24;

                    // Save changes to the distribution database properties.
                    distributionDb.CommitPropertyChanges();
                }
                else
                {
                    // Do something here if the distribution database does not exist.
                }
            }
            catch (Exception ex)
            {
                // Implement the appropriate error handling here. 
                throw new ApplicationException("An error occured when changing Distributor " +
                    " or distribution database properties.", ex);
            }
            finally
            {
                conn.Disconnect();
            }
' Set the Distributor and distribution database names.
Dim distributionDbName As String = "distribution"
Dim distributorName As String = publisherInstance

Dim distributor As ReplicationServer
Dim distributionDb As DistributionDatabase

' Create a connection to the Distributor using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(distributorName)

Try
    ' Open the connection. 
    conn.Connect()

    distributor = New ReplicationServer(conn)

    ' Load Distributor properties, if it is installed.
    If distributor.LoadProperties() Then
        ' Password supplied at runtime.
        distributor.ChangeDistributorPassword(password)
        distributor.AgentCheckupInterval = 5

        ' Save changes to the Distributor properties.
        distributor.CommitPropertyChanges()
    Else
        Throw New ApplicationException( _
            String.Format("{0} is not a Distributor.", publisherInstance))
    End If

    ' Create an object for the distribution database 
    ' using the open Distributor connection.
    distributionDb = New DistributionDatabase(distributionDbName, conn)

    ' Change distribution database properties.
    If distributionDb.LoadProperties() Then
        ' Change maximum retention period to 48 hours and history retention 
        ' period to 24 hours.
        distributionDb.MaxDistributionRetention = 48
        distributionDb.HistoryRetention = 24

        ' Save changes to the distribution database properties.
        distributionDb.CommitPropertyChanges()
    Else
        ' Do something here if the distribution database does not exist.
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here. 
    Throw New ApplicationException("An error occured when changing Distributor " + _
        " or distribution database properties.", ex)
Finally
    conn.Disconnect()
End Try