Share via


Subscription.Add Method

Adds a subscription record to the application database.

Spazio dei nomi: Microsoft.SqlServer.NotificationServices
Assembly : Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

Sintassi

'Dichiarazione
Public Function Add As String
public string Add ()
public:
virtual String^ Add () sealed
public final String Add ()
public final function Add () : String

Valore restituito

A string containing the subscription ID of the new subscription.

Osservazioni

When a new subscription is added to the database, Notification Services assigns it a unique subscription ID. Notification Services components use this subscription ID to identify the subscription.

Esempio

The following examples show how to use the Add method to add a subscription:

' 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")
 
 
' Set the properties that describe the subscription record.
testSubscription.Enabled = True
testSubscription.SubscriberId = "TestUser1"
 
' Set the subscription data fields (as defined in the ADF),
' using the indexer to set fields by field name.
testSubscription("DeviceName") = "Work e-mail"
testSubscription("SubscriberLocale") = "en-US"
testSubscription("City") = "Shoreline"
 
' Add the subscription to the database.
testSubscription.Add()
// 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");


// Set the properties that describe the subscription record.
testSubscription.Enabled = true;
testSubscription.SubscriberId = "TestUser1";

// Set the subscription data fields (as defined in the ADF),
// using the indexer to set fields by field name.
testSubscription["DeviceName"] = "Work e-mail";
testSubscription["SubscriberLocale"] = "en-US";
testSubscription["City"] = "Shoreline";

// Add the subscription to the database.
testSubscription.Add();

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.

Piattaforme

Piattaforme di sviluppo

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Piattaforme di destinazione

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Vedere anche

Riferimento

Subscription Class
Subscription Members
Microsoft.SqlServer.NotificationServices Namespace