TransPublication.RemovePullSubscription(String, String) TransPublication.RemovePullSubscription(String, String) TransPublication.RemovePullSubscription(String, String) Method

정의

게시자에서 끌어오기 구독 등록을 제거합니다. Removes the registration for a pull subscription at the Publisher.

public:
 void RemovePullSubscription(System::String ^ subscriber, System::String ^ subscriptionDB);
public void RemovePullSubscription (string subscriber, string subscriptionDB);
Public Sub RemovePullSubscription (subscriber As String, subscriptionDB As String)
매개 변수
subscriber
String String String

끌어오기 구독이 있는 구독자의 이름을 나타내는 String 값입니다. A String value that represents the name of the Subscriber where the pull subscription exists.

subscriptionDB
String String String

구독 데이터베이스 이름을 나타내는 String 값입니다. A String value that represents the subscription database name.

예제

// Define the Publisher, publication, and databases.
string publicationName = "AdvWorksProductTran";
string publisherName = publisherInstance;
string subscriberName = subscriberInstance;
string subscriptionDbName = "AdventureWorks2012Replica";
string publicationDbName = "AdventureWorks2012";

//Create connections to the Publisher and Subscriber.
ServerConnection subscriberConn = new ServerConnection(subscriberName);
ServerConnection publisherConn = new ServerConnection(publisherName);

// Create the objects that we need.
TransPublication publication;
TransPullSubscription subscription;

try
{
	// Connect to the Subscriber.
	subscriberConn.Connect();

	// Define the pull subscription.
	subscription = new TransPullSubscription();
	subscription.ConnectionContext = subscriberConn;
	subscription.PublisherName = publisherName;
	subscription.PublicationName = publicationName;
	subscription.PublicationDBName = publicationDbName;
	subscription.DatabaseName = subscriptionDbName;

	// Define the publication.
	publication = new TransPublication();
	publication.Name = publicationName;
	publication.DatabaseName = publicationDbName;
	publication.ConnectionContext = publisherConn;

	// Delete the pull subscription, if it exists.
	if (subscription.IsExistingObject)
	{
		if (publication.LoadProperties())
		{
                     // Remove the pull subscription registration at the Publisher.
			publication.RemovePullSubscription(subscriberName, subscriptionDbName);
		}
		else
		{
			// Do something here if the publication does not exist.
			throw new ApplicationException(String.Format(
				"The publication '{0}' does not exist on {1}.",
				publicationName, publisherName));
		}
                 // Delete the pull subscription at the Subscriber.
                 subscription.Remove();
	}
	else
	{
		throw new ApplicationException(String.Format(
			"The subscription to {0} does not exist on {1}",
			publicationName, subscriberName));
	}
}
catch (Exception ex)
{
	// Implement the appropriate error handling here.
	throw new ApplicationException(String.Format(
		"The subscription to {0} could not be deleted.", publicationName), ex);
}
finally
{
	subscriberConn.Disconnect();
	publisherConn.Disconnect();
}
' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksProductTran"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"

'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)

' Create the objects that we need.
Dim publication As TransPublication
Dim subscription As TransPullSubscription

Try
    ' Connect to the Subscriber.
    subscriberConn.Connect()

    ' Define the pull subscription.
    subscription = New TransPullSubscription()
    subscription.ConnectionContext = subscriberConn
    subscription.PublisherName = publisherName
    subscription.PublicationName = publicationName
    subscription.PublicationDBName = publicationDbName
    subscription.DatabaseName = subscriptionDbName

    ' Define the publication.
    publication = New TransPublication()
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName
    publication.ConnectionContext = publisherConn

    ' Delete the pull subscription, if it exists.
    If subscription.IsExistingObject Then
       
        If publication.LoadProperties() Then
            ' Remove the pull subscription registration at the Publisher.
            publication.RemovePullSubscription(subscriberName, subscriptionDbName)
        Else
            ' Do something here if the publication does not exist.
            Throw New ApplicationException(String.Format( _
             "The publication '{0}' does not exist on {1}.", _
             publicationName, publisherName))
        End If
        ' Delete the pull subscription at the Subscriber.
        subscription.Remove()
    Else
        Throw New ApplicationException(String.Format( _
         "The subscription to {0} does not exist on {1}", _
         publicationName, subscriberName))
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here.
    Throw New ApplicationException(String.Format( _
        "The subscription to {0} could not be deleted.", publicationName), ex)
Finally
    subscriberConn.Disconnect()
    publisherConn.Disconnect()
End Try

설명

RemovePullSubscription 의 멤버 메서드를 호출할 수만 sysadmin 고정된 서버 역할의 멤버에 의해 게시자에는 db_owner 게시 데이터베이스의 또는 제거 하 고 구독을 만든 사용자에 의해 고정된 데이터베이스 역할.The RemovePullSubscription method can only be called by members of the sysadmin fixed server role at the Publisher, by members of the db_owner fixed database role on the publication database, or by the user that created the subscription being removed.

호출 RemovePullSubscription 를 실행 하는 것과 같습니다 sp_dropsubscription합니다.Calling RemovePullSubscription is equivalent to executing sp_dropsubscription.

적용 대상