ReplicationServer.RegisteredSubscribers ReplicationServer.RegisteredSubscribers ReplicationServer.RegisteredSubscribers Property

정의

게시자에 등록된 구독자를 가져옵니다. Gets the Subscribers registered with the Publisher.

public:
 property Microsoft::SqlServer::Replication::RegisteredSubscriberCollection ^ RegisteredSubscribers { Microsoft::SqlServer::Replication::RegisteredSubscriberCollection ^ get(); };
public Microsoft.SqlServer.Replication.RegisteredSubscriberCollection RegisteredSubscribers { get; }
Public ReadOnly Property RegisteredSubscribers As RegisteredSubscriberCollection
속성 값

A RegisteredSubscriberCollection SQL Server 인스턴스의 현재 연결 된 게시자가 때 모든 등록 된 구독자를 나타내는 개체입니다. A RegisteredSubscriberCollection object that represents all the registered Subscribers when the currently connected instance of SQL Server is a Publisher.

예제

// Set the Distributor and publication database names.
// Publisher and Distributor are on the same server instance.
string publisherName = publisherInstance;
string distributorName = publisherInstance;
string distributionDbName = "distribution";
string publicationDbName = "AdventureWorks2012";

// Create connections to the Publisher and Distributor
// using Windows Authentication.
ServerConnection publisherConn = new ServerConnection(publisherName);
ServerConnection distributorConn = new ServerConnection(distributorName);

// Create the objects we need.
ReplicationServer distributor =
	new ReplicationServer(distributorConn);
DistributionPublisher publisher;
DistributionDatabase distributionDb =
	new DistributionDatabase(distributionDbName, distributorConn);
ReplicationDatabase publicationDb;
publicationDb = new ReplicationDatabase(publicationDbName, publisherConn);

try
{
	// Connect to the Publisher and Distributor.
	publisherConn.Connect();
	distributorConn.Connect();

	// Disable all publishing on the AdventureWorks2012 database.
	if (publicationDb.LoadProperties())
	{
		if (publicationDb.EnabledMergePublishing)
		{
			publicationDb.EnabledMergePublishing = false;
		}
		else if (publicationDb.EnabledTransPublishing)
		{
			publicationDb.EnabledTransPublishing = false;
		}
	}
	else
	{
		throw new ApplicationException(
			String.Format("The {0} database does not exist.", publicationDbName));
	}

	// We cannot uninstall the Publisher if there are still Subscribers.
	if (distributor.RegisteredSubscribers.Count == 0)
	{
		// Uninstall the Publisher, if it exists.
		publisher = new DistributionPublisher(publisherName, distributorConn);
		if (publisher.LoadProperties())
		{
			publisher.Remove(false);
		}
		else
		{
			// Do something here if the Publisher does not exist.
			throw new ApplicationException(String.Format(
				"{0} is not a Publisher for {1}.", publisherName, distributorName));
		}

		// Drop the distribution database.
		if (distributionDb.LoadProperties())
		{
			distributionDb.Remove();
		}
		else
		{
			// Do something here if the distribition DB does not exist.
			throw new ApplicationException(String.Format(
				"The distribution database '{0}' does not exist on {1}.",
				distributionDbName, distributorName));
		}

		// Uninstall the Distributor, if it exists.
		if (distributor.LoadProperties())
		{
			// Passing a value of false means that the Publisher 
			// and distribution databases must already be uninstalled,
			// and that no local databases be enabled for publishing.
			distributor.UninstallDistributor(false);
		}
		else
		{
			//Do something here if the distributor does not exist.
			throw new ApplicationException(String.Format(
				"The Distributor '{0}' does not exist.", distributorName));
		}
	}
	else
	{
		throw new ApplicationException("You must first delete all subscriptions.");
	}
}
catch (Exception ex)
{
	// Implement appropriate error handling here.
	throw new ApplicationException("The Publisher and Distributor could not be uninstalled", ex);
}
finally
{
	publisherConn.Disconnect();
	distributorConn.Disconnect();
}

설명

A RegisteredSubscriber 반환 된 개체 RegisteredSubscriberCollection 정수 또는 문자열 인덱서를 사용 하 여 액세스할 수 있습니다.A RegisteredSubscriber object in the returned RegisteredSubscriberCollection can be accessed using either an integer or a string indexer.

RegisteredSubscribers 공용 고정된 데이터베이스 역할 속성을 검색할 수 있습니다.The RegisteredSubscribers property can be retrieved by the public fixed database role.

적용 대상