Поделиться через


Класс DistributionDatabase

Represents a distribution database at the Distributor.

Иерархия наследования

System. . :: . .Object
  Microsoft.SqlServer.Replication. . :: . .ReplicationObject
    Microsoft.SqlServer.Replication..::..DistributionDatabase

Пространство имен:  Microsoft.SqlServer.Replication
Сборка:  Microsoft.SqlServer.Rmo (в Microsoft.SqlServer.Rmo.dll)

Синтаксис

'Декларация
Public NotInheritable Class DistributionDatabase _
    Inherits ReplicationObject
'Применение
Dim instance As DistributionDatabase
public sealed class DistributionDatabase : ReplicationObject
public ref class DistributionDatabase sealed : public ReplicationObject
[<SealedAttribute>]
type DistributionDatabase =  
    class
        inherit ReplicationObject
    end
public final class DistributionDatabase extends ReplicationObject

Тип DistributionDatabase обеспечивает доступ к следующим элементам.

Конструкторы

  Имя Описание
Открытый метод DistributionDatabase() () () () Creates a new instance of the DistributionDatabase class.
Открытый метод DistributionDatabase(String, ServerConnection) Creates a new instance of the DistributionDatabase class, with the specified database name and a connection to the Distributor.

В начало

Свойства

  Имя Описание
Открытое свойство CachePropertyChanges Gets or sets whether to cache changes made to the replication properties or to apply them immediately. (Производный от ReplicationObject.)
Открытое свойство ConnectionContext Gets or sets the connection to an instance of Microsoft SQL Server. (Производный от ReplicationObject.)
Открытое свойство DataFile Gets or sets the name of the data file for the distribution database.
Открытое свойство DataFileSize Gets or sets the size of the primary database file for the distribution database.
Открытое свойство DataFolder Gets or sets the path to the directory that contains the data file for the distribution database.
Открытое свойство DistributionCleanupTaskName Gets the name of the SQL Server Agent job that is responsible for cleaning up the replication tables in the distribution.
Открытое свойство DistributorSecurity Gets the security context used to connect to the Distributor to create the distribution database.
Открытое свойство HistoryCleanupTaskName Gets the name of the SQL Server Agent job that is responsible for cleaning up replication history tables.
Открытое свойство HistoryRetention Gets or sets the length of time, in hours, replication agent history data is to be retained.
Открытое свойство IsExistingObject Gets whether the object exists on the server or not. (Производный от ReplicationObject.)
Открытое свойство LogFile Gets or sets the name of the file that stores database transaction log records.
Открытое свойство LogFileSize Gets or sets the size of the file that stores database transaction log records.
Открытое свойство LogFolder Gets or sets the path to the directory where the file that stores database transaction log records is located.
Открытое свойство MaxDistributionRetention Gets or sets the maximum retention period, in hours, before transactions are deleted from the distribution database.
Открытое свойство MinDistributionRetention Gets or sets the minimum retention period, in hours, before transactions are deleted from the distribution database.
Открытое свойство Name Gets or sets the name of the distribution database.
Открытое свойство QueueReaderAgentExists Gets or sets whether the Queue Reader Agent job has been created for this distribution database.
Открытое свойство QueueReaderAgentName Gets or sets the name of the Queue Reader Agent job created for this distribution database.
Открытое свойство QueueReaderAgentProcessSecurity Gets the agent process security context for running the Queue Reader Agent job.
Открытое свойство SqlServerName Gets the name of the Microsoft SQL Server instance to which this object is connected. (Производный от ReplicationObject.)
Открытое свойство UserData Gets or sets an object property that allows users to attach their own data to the object. (Производный от ReplicationObject.)

В начало

Методы

  Имя Описание
Защищенный метод CheckValidCreation Инфраструктура. (Производный от ReplicationObject.)
Защищенный метод CheckValidDefinition Инфраструктура. (Производный от ReplicationObject.)
Открытый метод CleanUpAnonymousSubscription Removes metadata for anonymous subscriptions at the Distributor.
Открытый метод CommitPropertyChanges Sends all the cached property change statements to the instance of Microsoft SQL Server. (Производный от ReplicationObject.)
Открытый метод Create Creates the distribution database.
Открытый метод CreateQueueReaderAgent Creates the Queue Reader Agent job on the distribution database.
Открытый метод Decouple Decouples the referenced replication object from the server. (Производный от ReplicationObject.)
Открытый метод Equals (Производный от Object.)
Защищенный метод Finalize (Производный от Object.)
Защищенный метод GetChangeCommand Инфраструктура. (Производный от ReplicationObject.)
Защищенный метод GetCreateCommand Инфраструктура. (Производный от ReplicationObject.)
Защищенный метод GetDropCommand Инфраструктура. (Производный от ReplicationObject.)
Открытый метод GetHashCode (Производный от Object.)
Открытый метод GetType (Производный от Object.)
Защищенный метод InternalRefresh Инфраструктура. (Производный от ReplicationObject.)
Открытый метод Load Loads the properties of an existing object from the server. (Производный от ReplicationObject.)
Открытый метод LoadProperties Loads the properties of an existing object from the server. (Производный от ReplicationObject.)
Защищенный метод MemberwiseClone (Производный от Object.)
Открытый метод Refresh Reloads the properties of the object. (Производный от ReplicationObject.)
Открытый метод RegisterBusinessLogicHandler Registers a business logic handler assembly at the Distributor.
Открытый метод Remove Deletes the distribution database.
Открытый метод Script Generates a Transact-SQL script that can be used to create or delete the distribution database that the object represents.
Открытый метод ToString (Производный от Object.)
Открытый метод UnregisterBusinessLogicHandler Removes the registration for a business logic handler from the Distributor.

В начало

Замечания

This namespace, class, or member is supported only in version 2.0 of the .NET Framework.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Примеры

            // Set the server and database names
            string distributionDbName = "distribution";
            string publisherName = publisherInstance;
            string publicationDbName = "AdventureWorks2008R2";

            DistributionDatabase distributionDb;
            ReplicationServer distributor;
            DistributionPublisher publisher;
            ReplicationDatabase publicationDb;

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

            try
            {
                // Connect to the server acting as the Distributor 
                // and local Publisher.
                conn.Connect();

                // Define the distribution database at the Distributor,
                // but do not create it now.
                distributionDb = new DistributionDatabase(distributionDbName, conn);
                distributionDb.MaxDistributionRetention = 96;
                distributionDb.HistoryRetention = 120;

                // Set the Distributor properties and install the Distributor.
                // This also creates the specified distribution database.
                distributor = new ReplicationServer(conn);
                distributor.InstallDistributor((string)null, distributionDb);

                // Set the Publisher properties and install the Publisher.
                publisher = new DistributionPublisher(publisherName, conn);
                publisher.DistributionDatabase = distributionDb.Name;
                publisher.WorkingDirectory = @"\\" + publisherName + @"\repldata";
                publisher.PublisherSecurity.WindowsAuthentication = true;
                publisher.Create();

                // Enable AdventureWorks as a publication database.
                publicationDb = new ReplicationDatabase(publicationDbName, conn);

                publicationDb.EnabledTransPublishing = true;
                publicationDb.EnabledMergePublishing = true;
            }
            catch (Exception ex)
            {
                // Implement appropriate error handling here.
                throw new ApplicationException("An error occured when installing distribution and publishing.", ex);
            }
            finally
            {
                conn.Disconnect();
            }
' Set the server and database names
Dim distributionDbName As String = "distribution"
Dim publisherName As String = publisherInstance
Dim publicationDbName As String = "AdventureWorks2008R2"

Dim distributionDb As DistributionDatabase
Dim distributor As ReplicationServer
Dim publisher As DistributionPublisher
Dim publicationDb As ReplicationDatabase

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

Try
    ' Connect to the server acting as the Distributor 
    ' and local Publisher.
    conn.Connect()

    ' Define the distribution database at the Distributor,
    ' but do not create it now.
    distributionDb = New DistributionDatabase(distributionDbName, conn)
    distributionDb.MaxDistributionRetention = 96
    distributionDb.HistoryRetention = 120

    ' Set the Distributor properties and install the Distributor.
    ' This also creates the specified distribution database.
    distributor = New ReplicationServer(conn)
    distributor.InstallDistributor((CType(Nothing, String)), distributionDb)

    ' Set the Publisher properties and install the Publisher.
    publisher = New DistributionPublisher(publisherName, conn)
    publisher.DistributionDatabase = distributionDb.Name
    publisher.WorkingDirectory = "\\" + publisherName + "\repldata"
    publisher.PublisherSecurity.WindowsAuthentication = True
    publisher.Create()

    ' Enable AdventureWorks as a publication database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)

    publicationDb.EnabledTransPublishing = True
    publicationDb.EnabledMergePublishing = True

Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("An error occured when installing distribution and publishing.", ex)

Finally
    conn.Disconnect()

End Try

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.