Creating a Subscription Object
You must create an object of the Subscription class to add, delete, and update subscription information in a Notification Services application. The examples below show how to create a Subscription 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 Subscription object using the parameterized constructor. The Subscription object is usable immediately.
// Create the NSInstance object.
NSInstance testInstance = new NSInstance("Tutorial");
// Create the NSApplication object.
NSApplication testApplication =
new NSApplication(testInstance, "Weather");
// Create the Subscription object.
Subscription testSubscription =
new Subscription(testApplication, "WeatherCity");
COM Interop Example
The following VBScript example shows how to create and initialize the Subscription object via COM interop by using the default constructor to create the object and then calling the Initialize method to initialize it:
Dim testInstance, testApplication, testSubscription, subscriptionId
const instanceName = "Tutorial"
const applicationName = "Weather"
const subscriptionClassName = "WeatherCity"
' Create the NSInstance object.
set testInstance = WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.NSInstance")
testInstance.Initialize instanceName
' Create the NSApplication object.
set testApplication = WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.NSApplication")
testApplication.Initialize (testInstance), applicationName
' Create the Subscription object.
set testSubscription = WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.Subscription")
testSubscription.Initialize (testApplication), subscriptionClassName
See Also
Concepts
Adding a Subscription
Updating a Subscription
Deleting a Subscription
Getting Subscription Field Information
Populating a Subscriber Locale List
Populating a Time Zone List