구독자 레코드 추가
Subscriber 개체는 SubscriberId 값을 설정할 수 있도록 하고 구독자가 알림을 받도록 설정되어 있는지 여부를 나타내는 속성을 노출합니다. 이 개체의 Add 메서드는 인스턴스 데이터베이스에 해당 데이터를 씁니다.
[!참고] Notification Services 인스턴스 데이터베이스에 대해 선택한 데이터 정렬에 따라 SubscriberId가 고유한지 평가할 때 대/소문자 및 선행 또는 후행 공백이 검사될 수 있습니다.
관리 코드 예
다음 코드 예에서는 관리 코드에서 Subscriber 개체를 사용하여 구독자를 추가하는 방법을 보여 줍니다. 이 예에서는 Enabled 및 SubscriberId 속성의 리터럴 값을 사용하지만 구독 관리 인터페이스에서 해당 속성 값을 가져오게 됩니다.
// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);
// Create the Subscriber object.
Subscriber testSubscriber = new Subscriber(testInstance);
// Set the properties that describe the subscriber record.
testSubscriber.Enabled = true;
testSubscriber.SubscriberId = "TestUser1";
// Add the subscriber record to the database.
testSubscriber.Add();
COM Interop 예
다음 Microsoft VBScript(Visual Basic Scripting Edition) 코드 예에서는 비관리 코드에서 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)
wscript.echo "Subscriber object created."
' Set the properties that describe the subscriber record.
testSubscriber.SubscriberId = "TestUser2"
testSubscriber.Enabled = true
' Add the subscriber record to the database.
testSubscriber.Add
wscript.echo "Subscriber added."
참고 항목
개념
구독자 개체 만들기
구독자 레코드 업데이트
구독자 레코드 삭제
관련 구독 정보 삭제
구독자 장치 및 구독 가져오기