Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DistributionDatabase Class

 

Applies To: SQL Server 2016 Preview

Represents a distribution database at the Distributor.

Namespace:   Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Rmo (in Microsoft.SqlServer.Rmo.dll)

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

public sealed class DistributionDatabase : ReplicationObject

NameDescription
System_CAPS_pubmethodDistributionDatabase()

Creates a new instance of the DistributionDatabase class.

System_CAPS_pubmethodDistributionDatabase(String, ServerConnection)

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

NameDescription
System_CAPS_pubpropertyCachePropertyChanges

Gets or sets whether to cache changes made to the replication properties or to apply them immediately.(Inherited from ReplicationObject.)

System_CAPS_pubpropertyConnectionContext

Gets or sets the connection to an instance of Microsoft SQL Server.(Inherited from ReplicationObject.)

System_CAPS_pubpropertyDataFile

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

System_CAPS_pubpropertyDataFileSize

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

System_CAPS_pubpropertyDataFolder

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

System_CAPS_pubpropertyDistributionCleanupTaskName

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

System_CAPS_pubpropertyDistributorSecurity

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

System_CAPS_pubpropertyHistoryCleanupTaskName

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

System_CAPS_pubpropertyHistoryRetention

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

System_CAPS_pubpropertyIsExistingObject

Gets whether the object exists on the server or not.(Inherited from ReplicationObject.)

System_CAPS_pubpropertyLogFile

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

System_CAPS_pubpropertyLogFileSize

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

System_CAPS_pubpropertyLogFolder

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

System_CAPS_pubpropertyMaxDistributionRetention

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

System_CAPS_pubpropertyMinDistributionRetention

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

System_CAPS_pubpropertyName

Gets or sets the name of the distribution database.

System_CAPS_pubpropertyQueueReaderAgentExists

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

System_CAPS_pubpropertyQueueReaderAgentName

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

System_CAPS_pubpropertyQueueReaderAgentProcessSecurity

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

System_CAPS_pubpropertySqlServerName

Gets the name of the Microsoft SQL Server instance to which this object is connected. (Inherited from ReplicationObject.)

System_CAPS_pubpropertyUserData

Gets or sets an object property that allows users to attach their own data to the object. (Inherited from ReplicationObject.)

NameDescription
System_CAPS_pubmethodCleanUpAnonymousSubscription(Int32, PublicationType)

Removes metadata for anonymous subscriptions at the Distributor.

System_CAPS_pubmethodCommitPropertyChanges()

Sends all the cached property change statements to the instance of Microsoft SQL Server.(Inherited from ReplicationObject.)

System_CAPS_pubmethodCreate()

Creates the distribution database.

System_CAPS_pubmethodCreateQueueReaderAgent()

Creates the Queue Reader Agent job on the distribution database.

System_CAPS_pubmethodDecouple()

Decouples the referenced replication object from the server. (Inherited from ReplicationObject.)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodLoad()

Loads the properties of an existing object from the server. (Inherited from ReplicationObject.)

System_CAPS_pubmethodLoadProperties()

Loads the properties of an existing object from the server. (Inherited from ReplicationObject.)

System_CAPS_pubmethodRefresh()

Reloads the properties of the object. (Inherited from ReplicationObject.)

System_CAPS_pubmethodRegisterBusinessLogicHandler(BusinessLogicHandler)

Registers a business logic handler assembly at the Distributor.

System_CAPS_pubmethodRemove()

Deletes the distribution database.

System_CAPS_pubmethodScript(ScriptOptions)

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

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodUnregisterBusinessLogicHandler(BusinessLogicHandler)

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

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.

Legacy Code Example

			// 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();
			}

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

Return to top

Community Additions

Show:
© 2015 Microsoft