使用 SubscriberDevice 类的 Update 方法,可以修改 Notification Services 实例数据库中的现有订阅方设备数据。以下示例显示了如何使用托管代码和 Microsoft Visual Basic Scripting Edition (VBScript) 更新订阅方设备,以演示 COM interop。
托管代码示例
以下示例代码显示了如何使用托管代码形式的 SubscriberDevice 对象来更新订阅方设备。
string instanceName = "Tutorial";
// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);
// Create the SubscriberDevice object.
SubscriberDevice testSubscriberDevice =
new SubscriberDevice(testInstance);
// Set the subscriber ID and device name
// so that the correct record is updated.
testSubscriberDevice.SubscriberId = "TestUser1";
testSubscriberDevice.DeviceName = "Work e-mail";
// Modify the subscriber device properties
// and update the record.
testSubscriberDevice.DeviceAddress = "stephanieb@adventure-works.com";
testSubscriberDevice.DeviceTypeName = "e-mail";
testSubscriberDevice.DeliveryChannelName = "FileChannel";
testSubscriberDevice.Update();
COM Interop 示例
以下 VBScript 示例显示了如何使用非托管代码形式的 SubscriberDevice 对象来更新订阅方设备:
Dim testInstance, testSubscriberDevice
const instanceName = "Tutorial"
' Create the NSInstance object.
set testInstance = _
WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.NSInstance")
testInstance.Initialize instanceName
' Create the SubscriberDevice object.
set testSubscriberDevice = _
WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.SubscriberDevice")
testSubscriberDevice.Initialize (testInstance)
' Set the subscriber ID and device name
' so that the correct record is updated.
testSubscriberDevice.SubscriberId = "TestUser2"
testSubscriberDevice.DeviceName = "Work e-mail"
' Modify the subscriber device properties
' and update the record.
testSubscriberDevice.DeviceAddress = "davidb@adventure-works.com"
testSubscriberDevice.DeviceTypeName = "e-mail"
testSubscriberDevice.DeliveryChannelName = "FileChannel"
testSubscriberDevice.Update()
wscript.echo "Subscriber device updated."
请参阅
概念
创建 SubscriberDevice 对象
添加订阅方设备
删除订阅方设备
填充传递通道列表