Updating a Subscriber Record

Use the Update method of the Subscriber class to modify existing subscriber data in the Notification Services database. You access a subscriber record by creating a Subscriber object and then setting the SubscriberId property, or using a SubscriberEnumeration object to get the collection of subscribers for the Notification Services instance.

Managed Code Example

The following code example shows how to use a Subscriber object in managed code to update a subscriber.

This example uses the Microsoft.SqlServer.NotificationServices namespace.

string instanceName = "Tutorial";    

// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);

// Create the Subscriber object.
Subscriber testSubscriber = new Subscriber(testInstance);        

// Set the subscriber ID so that the correct
// subscriber record is updated.
testSubscriber.SubscriberId = "TestUser1";

// Change subscriber data, then update the database.
testSubscriber.Enabled = false;
testSubscriber.Update();

COM Interop Example

The following Microsoft Visual Basic Scripting Edition (VBScript) code example shows how to use a Subscriber object in unmanaged code to update a subscriber:

Dim testInstance, testSubscriber

const instanceName = "Tutorial"

' Create and initialize the NSInstance object.
set testInstance = _
    WScript.CreateObject( _
    "Microsoft.SqlServer.NotificationServices.NSInstance")

testInstance.Initialize instanceName

' Create and initialize the Subscriber object.
set testSubscriber = _ 
    WScript.CreateObject( _ 
    "Microsoft.SqlServer.NotificationServices.Subscriber")

testSubscriber.Initialize (testInstance)

' Set the subscriber ID.
testSubscriber.SubscriberId = "TestUser2"

' Set properties and update the subscriber record
testSubscriber.Enabled = false
testSubscriber.Update

wscript.echo "Subscriber updated."

See Also

Concepts

Creating a Subscriber Object
Adding a Subscriber Record
Deleting a Subscriber Record
Deleting Related Subscription Information
Getting a Subscriber's Devices and Subscriptions

Other Resources

NSSubscriberView

Help and Information

Getting SQL Server 2005 Assistance