DistributionDatabase DistributionDatabase DistributionDatabase DistributionDatabase Class

Definition

Represents a distribution database at the Distributor.

public ref class DistributionDatabase sealed : Microsoft::SqlServer::Replication::ReplicationObject
public sealed class DistributionDatabase : Microsoft.SqlServer.Replication.ReplicationObject
type DistributionDatabase = class
    inherit ReplicationObject
Public NotInheritable Class DistributionDatabase
Inherits ReplicationObject
Inheritance
DistributionDatabaseDistributionDatabaseDistributionDatabaseDistributionDatabase

Examples

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

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

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

Remarks

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.

Constructors

DistributionDatabase() DistributionDatabase() DistributionDatabase() DistributionDatabase()

Creates a new instance of the DistributionDatabase class.

DistributionDatabase(String, ServerConnection) DistributionDatabase(String, ServerConnection) DistributionDatabase(String, ServerConnection) DistributionDatabase(String, ServerConnection)

Creates a new instance of the DistributionDatabase class, with the specified database name and a connection to the Distributor.

Properties

CachePropertyChanges CachePropertyChanges CachePropertyChanges CachePropertyChanges

Gets or sets whether to cache changes made to the replication properties or to apply them immediately.

(Inherited from ReplicationObject)
ConnectionContext ConnectionContext ConnectionContext ConnectionContext

Gets or sets the connection to an instance of Microsoft SQL Server.

(Inherited from ReplicationObject)
DataFile DataFile DataFile DataFile

Gets or sets the name of the data file for the distribution database.

DataFileSize DataFileSize DataFileSize DataFileSize

Gets or sets the size of the primary database file for the distribution database.

DataFolder DataFolder DataFolder DataFolder

Gets or sets the path to the directory that contains the data file for the distribution database.

DistributionCleanupTaskName DistributionCleanupTaskName DistributionCleanupTaskName DistributionCleanupTaskName

Gets the name of the SQL Server Agent job that is responsible for cleaning up the replication tables in the distribution.

DistributorSecurity DistributorSecurity DistributorSecurity DistributorSecurity

Gets the security context used to connect to the Distributor to create the distribution database.

HistoryCleanupTaskName HistoryCleanupTaskName HistoryCleanupTaskName HistoryCleanupTaskName

Gets the name of the SQL Server Agent job that is responsible for cleaning up replication history tables.

HistoryRetention HistoryRetention HistoryRetention HistoryRetention

Gets or sets the length of time, in hours, replication agent history data is to be retained.

IsExistingObject IsExistingObject IsExistingObject IsExistingObject

Gets whether the object exists on the server or not.

(Inherited from ReplicationObject)
LogFile LogFile LogFile LogFile

Gets or sets the name of the file that stores database transaction log records.

LogFileSize LogFileSize LogFileSize LogFileSize

Gets or sets the size of the file that stores database transaction log records.

LogFolder LogFolder LogFolder LogFolder

Gets or sets the path to the directory where the file that stores database transaction log records is located.

MaxDistributionRetention MaxDistributionRetention MaxDistributionRetention MaxDistributionRetention

Gets or sets the maximum retention period, in hours, before transactions are deleted from the distribution database.

MinDistributionRetention MinDistributionRetention MinDistributionRetention MinDistributionRetention

Gets or sets the minimum retention period, in hours, before transactions are deleted from the distribution database.

Name Name Name Name

Gets or sets the name of the distribution database.

QueueReaderAgentExists QueueReaderAgentExists QueueReaderAgentExists QueueReaderAgentExists

Gets or sets whether the Queue Reader Agent job has been created for this distribution database.

QueueReaderAgentName QueueReaderAgentName QueueReaderAgentName QueueReaderAgentName

Gets or sets the name of the Queue Reader Agent job created for this distribution database.

QueueReaderAgentProcessSecurity QueueReaderAgentProcessSecurity QueueReaderAgentProcessSecurity QueueReaderAgentProcessSecurity

Gets the agent process security context for running the Queue Reader Agent job.

SqlServerName SqlServerName SqlServerName SqlServerName

Gets the name of the Microsoft SQL Server instance to which this object is connected.

(Inherited from ReplicationObject)
UserData UserData UserData UserData

Gets or sets an object property that allows users to attach their own data to the object.

(Inherited from ReplicationObject)

Methods

CheckValidCreation() CheckValidCreation() CheckValidCreation() CheckValidCreation()

Checks the valid replication creation.

(Inherited from ReplicationObject)
CheckValidDefinition(Boolean) CheckValidDefinition(Boolean) CheckValidDefinition(Boolean) CheckValidDefinition(Boolean)

Indicates whether the definition is valid.

(Inherited from ReplicationObject)
CleanUpAnonymousSubscription(Int32, PublicationType) CleanUpAnonymousSubscription(Int32, PublicationType) CleanUpAnonymousSubscription(Int32, PublicationType) CleanUpAnonymousSubscription(Int32, PublicationType)

Removes metadata for anonymous subscriptions at the Distributor.

CommitPropertyChanges() CommitPropertyChanges() CommitPropertyChanges() CommitPropertyChanges()

Sends all the cached property change statements to the instance of Microsoft SQL Server.

(Inherited from ReplicationObject)
Create() Create() Create() Create()

Creates the distribution database.

CreateQueueReaderAgent() CreateQueueReaderAgent() CreateQueueReaderAgent() CreateQueueReaderAgent()

Creates the Queue Reader Agent job on the distribution database.

Decouple() Decouple() Decouple() Decouple()

Decouples the referenced replication object from the server.

(Inherited from ReplicationObject)
GetChangeCommand(StringBuilder, String, String) GetChangeCommand(StringBuilder, String, String) GetChangeCommand(StringBuilder, String, String) GetChangeCommand(StringBuilder, String, String)

Returns the change command from the replication.

(Inherited from ReplicationObject)
GetCreateCommand(StringBuilder, Boolean, ScriptOptions) GetCreateCommand(StringBuilder, Boolean, ScriptOptions) GetCreateCommand(StringBuilder, Boolean, ScriptOptions) GetCreateCommand(StringBuilder, Boolean, ScriptOptions)

Returns the create command from the replication.

(Inherited from ReplicationObject)
GetDropCommand(StringBuilder, Boolean) GetDropCommand(StringBuilder, Boolean) GetDropCommand(StringBuilder, Boolean) GetDropCommand(StringBuilder, Boolean)

Returns the drop command from the replication.

(Inherited from ReplicationObject)
InternalRefresh(Boolean) InternalRefresh(Boolean) InternalRefresh(Boolean) InternalRefresh(Boolean)

Initiates an internal refresh from the replication.

(Inherited from ReplicationObject)
Load() Load() Load() Load()

Loads the properties of an existing object from the server.

(Inherited from ReplicationObject)
LoadProperties() LoadProperties() LoadProperties() LoadProperties()

Loads the properties of an existing object from the server.

(Inherited from ReplicationObject)
Refresh() Refresh() Refresh() Refresh()

Reloads the properties of the object.

(Inherited from ReplicationObject)
RegisterBusinessLogicHandler(BusinessLogicHandler) RegisterBusinessLogicHandler(BusinessLogicHandler) RegisterBusinessLogicHandler(BusinessLogicHandler) RegisterBusinessLogicHandler(BusinessLogicHandler)

Registers a business logic handler assembly at the Distributor.

Remove() Remove() Remove() Remove()

Deletes the distribution database.

Script(ScriptOptions) Script(ScriptOptions) Script(ScriptOptions) Script(ScriptOptions)

Generates a Transact-SQL script that can be used to create or delete the distribution database that the object represents.

UnregisterBusinessLogicHandler(BusinessLogicHandler) UnregisterBusinessLogicHandler(BusinessLogicHandler) UnregisterBusinessLogicHandler(BusinessLogicHandler) UnregisterBusinessLogicHandler(BusinessLogicHandler)

Removes the registration for a business logic handler from the Distributor.

Applies to

See also