创建订阅对象
必须创建 Subscription 类的对象,才能在 Notification Services 应用程序中添加、删除和更新订阅信息。下面的示例说明如何使用托管代码创建 Subscription 对象以及如何使用 Microsoft Visual Basic Scripting Edition (VBScript) 说明 COM interop。
托管代码示例
下面的代码示例说明如何使用参数化构造函数创建并初始化 Subscription 对象。Subscription 对象立即可用。
// 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 示例
下面的 VBScript 示例说明如何通过使用默认构造函数创建对象,然后调用 Initialize 方法初始化该对象,来通过 COM interop 创建并初始化 Subscription 对象:
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
请参阅
概念
添加订阅
更新订阅
删除订阅
获取订阅字段信息
填充订阅服务器区域设置列表
填充时区列表