Compartilhar via


Subscription.Update Method

Updates the information in a subscription record.

Namespace: Microsoft.SqlServer.NotificationServices
Assembly: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

Syntax

'Declaration
Public Sub Update
public void Update ()
public:
virtual void Update () sealed
public final void Update ()
public final function Update ()

Remarks

The update applies to the record identified by the subscription ID.

Example

The following examples show how to use the Update method to modify subscription information:

' Create the NSInstance object.
Dim testInstance As New NSInstance("Tutorial")
 
' Create the NSApplication object.
Dim testApplication As _
    New NSApplication(testInstance, "Weather")
 
' Create the Subscription object.
Dim testSubscription As _
    New Subscription(testApplication, "WeatherCity")
 
 
'Create a SubscriptionEnumeration object.
' that contains all of the subscriber's subscriptions
' in a specific subscription class
Dim testSubscriptionEnumeration As _
    New SubscriptionEnumeration(testApplication, "WeatherCity", "TestUser1")
 
'Iterate through the subscriptions, finding the subscription
' to match. In a user interface, you would probably list the 
' subscriptions in a list box and then let the user
' alter the data for the selected subscription
Dim subscription As Subscription
For Each subscription In testSubscriptionEnumeration
    Dim city As String =  subscription.GetFieldValue("City").ToString() 
    Console.WriteLine(city)
    Console.WriteLine("Subscription ID: {0}", subscription.SubscriptionId)
    If city.Equals("Shoreline") Then
         testSubscription.SubscriptionId = subscription.SubscriptionId
    End If
Next
 
' Set all of the subscription data fields 
testSubscription("DeviceName") = "Work e-mail"
testSubscription("SubscriberLocale") = "en-US"
testSubscription("City") = "Edmonds"
 
testSubscription.Update()
// 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");


//Create a SubscriptionEnumeration object.
// that contains all of the subscriber's subscriptions
// in a specific subscription class
SubscriptionEnumeration testSubscriptionEnumeration = 
    new SubscriptionEnumeration(testApplication, 
        "WeatherCity", "TestUser1");

//Iterate through the subscriptions, finding the subscription
// to match. In a user interface, you would probably list the 
// subscriptions in a list box and then let the user
// alter the data for the selected subscription
foreach (Subscription subscription in testSubscriptionEnumeration)
{
    String city = subscription.GetFieldValue("City").ToString();
    Console.WriteLine(city);
    Console.WriteLine("Subscription ID: {0}", subscription.SubscriptionId);
        if (city.Equals("Shoreline"))
            testSubscription.SubscriptionId = subscription.SubscriptionId;
}

// Set all of the subscription data fields 
testSubscription["DeviceName"] = "Work e-mail";
testSubscription["SubscriberLocale"] = "en-US";
testSubscription["City"] = "Edmonds";

testSubscription.Update();

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

See Also

Reference

Subscription Class
Subscription Members
Microsoft.SqlServer.NotificationServices Namespace