다음을 통해 공유


관련 구독 정보 삭제

Subscriber 클래스의 DeleteSubscriptions 메서드는 지정된 구독자에 대한 기존 구독 레코드를 삭제합니다. 관련된 모든 구독을 삭제할 수도 있고 한 응용 프로그램에 대한 구독이나 한 응용 프로그램의 특정 구독 클래스에 대한 구독만 삭제할 수도 있습니다. 아래 예에서는 구독자의 구독을 삭제하기 위해 관리 코드를 사용하는 방법과 COM interop을 나타내는 Microsoft VBScript(Visual Basic Scripting Edition)를 사용하는 방법을 보여 줍니다.

관리 코드 예: 모든 구독 삭제

다음 코드 예에서는 관리 코드에서 Subscriber 개체를 사용하여 구독자에 속하는 모든 구독을 삭제하는 방법을 보여 줍니다.

string instanceName = "Tutorial";

// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);

// Create the Subscriber object.
Subscriber testSubscriber = new Subscriber(testInstance);

// Set the subscriber ID so that the correct
// subscriber record is updated.
testSubscriber.SubscriberId = "TestUser1";

// Change subscriber data, then update the database.
testSubscriber.DeleteSubscriptions();

DeleteSubscriptions 메서드의 오버로드를 사용하여 단일 응용 프로그램이나 단일 구독 클래스에 대한 구독을 삭제할 수도 있습니다.

COM Interop 예: 모든 구독 삭제

다음 VBScript 코드 예에서는 비관리 코드에서 Subscriber 개체를 사용하여 구독자에 속하는 모든 구독을 삭제하는 방법을 보여 줍니다.

Dim testInstance, testSubscriber
const instanceName = "Tutorial"

' Create and initialize the NSInstance object.
set testInstance = WScript.CreateObject( _
    "Microsoft.SqlServer.NotificationServices.NSInstance")
testInstance.Initialize instanceName

' Create and initialize the Subscriber object.
set testSubscriber = WScript.CreateObject( _ 
    "Microsoft.SqlServer.NotificationServices.Subscriber")
testSubscriber.Initialize (testInstance)

' Set the subscriber ID.
testSubscriber.SubscriberId = "TestUser2"

' Delete the subscriber record
testSubscriber.DeleteSubscriptions Nothing, ""

wscript.echo "All TestUser2 subscriptions deleted."

참고 항목

개념

구독자 레코드 삭제
구독 삭제
구독자 개체 만들기
구독자 레코드 추가
구독자 레코드 업데이트
구독자 장치 및 구독 가져오기

관련 자료

NSSubscriberView

도움말 및 정보

SQL Server 2005 지원 받기