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 sealed class DistributionDatabase : 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.
맨 위로 이동

  이름설명
공용 속성CachePropertyChangesGets or sets whether to cache changes made to the replication properties or to apply them immediately. (ReplicationObject에서 상속됨)
공용 속성ConnectionContextGets or sets the connection to an instance of Microsoft SQL Server. (ReplicationObject에서 상속됨)
공용 속성DataFileGets or sets the name of the data file for the distribution database.
공용 속성DataFileSizeGets or sets the size of the primary database file for the distribution database.
공용 속성DataFolderGets or sets the path to the directory that contains the data file for the distribution database.
공용 속성DistributionCleanupTaskNameGets the name of the SQL Server Agent job that is responsible for cleaning up the replication tables in the distribution.
공용 속성DistributorSecurityGets the security context used to connect to the Distributor to create the distribution database.
공용 속성HistoryCleanupTaskNameGets the name of the SQL Server Agent job that is responsible for cleaning up replication history tables.
공용 속성HistoryRetentionGets or sets the length of time, in hours, replication agent history data is to be retained.
공용 속성IsExistingObjectGets whether the object exists on the server or not. (ReplicationObject에서 상속됨)
공용 속성LogFileGets or sets the name of the file that stores database transaction log records.
공용 속성LogFileSizeGets or sets the size of the file that stores database transaction log records.
공용 속성LogFolderGets or sets the path to the directory where the file that stores database transaction log records is located.
공용 속성MaxDistributionRetentionGets or sets the maximum retention period, in hours, before transactions are deleted from the distribution database.
공용 속성MinDistributionRetentionGets or sets the minimum retention period, in hours, before transactions are deleted from the distribution database.
공용 속성NameGets or sets the name of the distribution database.
공용 속성QueueReaderAgentExistsGets or sets whether the Queue Reader Agent job has been created for this distribution database.
공용 속성QueueReaderAgentNameGets or sets the name of the Queue Reader Agent job created for this distribution database.
공용 속성QueueReaderAgentProcessSecurityGets the agent process security context for running the Queue Reader Agent job.
공용 속성SqlServerNameGets the name of the Microsoft SQL Server instance to which this object is connected. (ReplicationObject에서 상속됨)
공용 속성UserDataGets or sets an object property that allows users to attach their own data to the object. (ReplicationObject에서 상속됨)
맨 위로 이동

  이름설명
공용 메서드CleanUpAnonymousSubscriptionRemoves metadata for anonymous subscriptions at the Distributor.
공용 메서드CommitPropertyChangesSends all the cached property change statements to the instance of Microsoft SQL Server. (ReplicationObject에서 상속됨)
공용 메서드CreateCreates the distribution database.
공용 메서드CreateQueueReaderAgentCreates the Queue Reader Agent job on the distribution database.
공용 메서드DecoupleDecouples the referenced replication object from the server. (ReplicationObject에서 상속됨)
공용 메서드Equals (Object에서 상속됨)
공용 메서드GetHashCode (Object에서 상속됨)
공용 메서드GetType (Object에서 상속됨)
공용 메서드LoadLoads the properties of an existing object from the server. (ReplicationObject에서 상속됨)
공용 메서드LoadPropertiesLoads the properties of an existing object from the server. (ReplicationObject에서 상속됨)
공용 메서드RefreshReloads the properties of the object. (ReplicationObject에서 상속됨)
공용 메서드RegisterBusinessLogicHandlerRegisters a business logic handler assembly at the Distributor.
공용 메서드RemoveDeletes the distribution database.
공용 메서드ScriptGenerates a Transact-SQL script that can be used to create or delete the distribution database that the object represents.
공용 메서드ToString (Object에서 상속됨)
공용 메서드UnregisterBusinessLogicHandlerRemoves the registration for a business logic handler from the Distributor.
맨 위로 이동

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

이 유형의 모든 공용 static(Visual Basic에서는 Shared) 멤버는 스레드로부터 안전합니다. 인스턴스 멤버는 스레드로부터의 안전성이 보장되지 않습니다.

커뮤니티 추가 항목

추가
표시: