删除订阅方设备
SubscriberDevice 类的 Delete 方法可以删除 Notification Services 数据库中的现有订阅方设备记录。以下示例显示了如何使用托管代码和 Microsoft Visual Basic Scripting Edition (VBScript) 来删除订阅方设备,以演示 COM interop。
如果删除最后一个订阅方设备,则 Notification Services 将为订阅方设备表中的订阅方留出一行,但将该订阅方的所有属性设置为 NULL。
托管代码示例
以下示例代码显示了如何使用托管代码形式的 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 deleted.
testSubscriberDevice.SubscriberId = "TestUser1";
testSubscriberDevice.DeviceName = "Work E-mail";
// Delete the device
testSubscriberDevice.Delete();
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 deleted.
testSubscriberDevice.SubscriberId = "TestUser2"
testSubscriberDevice.DeviceName = "Work e-mail"
' Delete the device
testSubscriberDevice.Delete()
wscript.echo "Subscriber device deleted."
请参阅
概念
创建 SubscriberDevice 对象
添加订阅方设备
更新订阅方设备
填充传递通道列表