Jaa


Subscriber.GetSubscriptions Method

Gets all of the subscriber's subscriptions for the specified subscription class in the specified Notification Services application.

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

Syntax

'Declaration
Public Function GetSubscriptions ( _
    nsApplication As NSApplication, _
    subscriptionClassName As String _
) As SubscriptionEnumeration
public SubscriptionEnumeration GetSubscriptions (
    NSApplication nsApplication,
    string subscriptionClassName
)
public:
virtual SubscriptionEnumeration^ GetSubscriptions (
    NSApplication^ nsApplication, 
    String^ subscriptionClassName
) sealed
public final SubscriptionEnumeration GetSubscriptions (
    NSApplication nsApplication, 
    String subscriptionClassName
)
public final function GetSubscriptions (
    nsApplication : NSApplication, 
    subscriptionClassName : String
) : SubscriptionEnumeration

Parameters

  • nsApplication
    An NSApplication that represents the Notification Services application containing the specified subscription class.
  • subscriptionClassName
    A String containing the name of the subscription class for which all subscriptions for this subscriber should be retrieved.

Return Value

A SubscriptionEnumeration that contains all subscriptions for the subscriber for the specified Notification Services application and subscription class. To see all subscription classes for an application, use the Microsoft.SqlServer.Management.Nmo.SubscriptionClass class.

Example

The following examples show how to use the GetSubscriptions method to retrieve all subscriptions in one subscription class of one Notification Services application for a subscriber:

Dim instanceName As String =  "Tutorial" 
Dim applicationName As String =  "Weather" 
Dim subscriptionClassName As String =  "WeatherCity" 
Dim subscriptionFieldName As String =  "City" 
 
' Create the NSInstance object.
Dim testInstance As NSInstance =  New NSInstance(instanceName) 
 
' Create the Subscriber object.
Dim testSubscriber As Subscriber =  New Subscriber(testInstance) 
 
' Set the subscriber ID so that the
' correct records are retrieved. 
testSubscriber.SubscriberId = "TestUser1"
 
' Create the NSApplication object.
Dim testApplication As NSApplication = _
    New NSApplication(testInstance, applicationName)
 
' Retrieve the subscriber's subscriptions.
Dim testSubscriptionEnumeration As SubscriptionEnumeration = _
    testSubscriber.GetSubscriptions( _
    testApplication, subscriptionClassName)
 
Dim singleSub As Subscription
For Each singleSub In testSubscriptionEnumeration
    Console.WriteLine(singleSub(subscriptionFieldName).ToString())
Next
Console.ReadLine()
string instanceName = "Tutorial";
string applicationName = "Weather";
string subscriptionClassName = "WeatherCity";
string subscriptionFieldName = "City";

// 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 records are retrieved. 
testSubscriber.SubscriberId = "TestUser1";

// Create the NSApplication object.
NSApplication testApplication =
    new NSApplication(testInstance, applicationName);

// Retrieve the subscriber's subscriptions.
SubscriptionEnumeration testSubscriptionEnumeration =
    testSubscriber.GetSubscriptions
    (testApplication, subscriptionClassName);

foreach (Subscription singleSub in testSubscriptionEnumeration)
{
    Console.WriteLine(singleSub[subscriptionFieldName].ToString());
}
Console.ReadLine();

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

Subscriber Class
Subscriber Members
Microsoft.SqlServer.NotificationServices Namespace