Creating a Subscriber Object
Use the Subscriber class to add, delete, or update subscriber information in an instance of Notification Services. The examples below show how to create a Subscriber object using managed code and using Microsoft Visual Basic Scripting Edition (VBScript) to illustrate COM interop.
Managed Code Example
The following code example shows how to create and initialize the Subscriber object by using the parameterized constructor to pass in the name of the Notification Services instance. The Subscriber object is usable immediately.
// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);
// Create the Subscriber object.
Subscriber testSubscriber = new Subscriber(testInstance);
COM Interop Example
The following VBScript example shows how to create and initialize the Subscriber object via COM interop by using the parameterless constructor to create the object and then calling the Initialize method to initialize it:
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."
See Also
Concepts
Adding a Subscriber Record
Updating a Subscriber Record
Deleting a Subscriber Record
Deleting Related Subscription Information
Getting a Subscriber's Devices and Subscriptions