Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Delete method of the SubscriberDevice class deletes an existing subscriber device record in the Notification Services database. The examples below show how to delete a subscriber device using managed code and using Microsoft Visual Basic Scripting Edition (VBScript) to illustrate COM interop.
If you delete the last subscriber device, Notification Services leaves a row for the subscriber in the subscriber device table, but sets all of its properties to NULL.
Managed Code Example
The following code example shows how to use a SubscriberDevice object in managed code to delete a subscriber device.
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 Example
The following VBScript example shows how to use a SubscriberDevice object in unmanaged code to delete a subscriber device:
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."
See Also
Concepts
Creating a SubscriberDevice Object
Adding a Subscriber Device
Updating a Subscriber Device
Populating a Delivery Channel List