Showing posts with label ssns. Show all posts
Showing posts with label ssns. Show all posts

Tuesday, March 20, 2012

adding subscriptions

Hi everyone,

Im not into VB scripting...On SSNS, im trying to add subscribers and subscriptions using VBscript.
I have been successful in adding subscribers but am getting an error while trying to add subscriptions... here's my code and the error:

PS: the tutorial code doesnt help much though it is very very similar, coz it is throwing up its own errors.

'
' AddSubscriptions.vbs
'
' Add a set of subscriptions to the ********** application
'
AddSubscriptions

Function AddSubscriptions()
Dim nsInstance, nsApplication, nsSubscription
' Create NSInstance object
Set nsInstance =
WScript.CreateObject("Microsoft.SqlServer.NotificationServices.NSInstance")
nsInstance.Initialize "*******"

' Create NSApplication object
Set nsApplication =
WScript.CreateObject("Microsoft.SqlServer.NotificationServices.NSApplication")
nsApplication.Initialize (nsInstance), "**********"
' Create NSSubscription object
Set nsSubscription =
WScript.CreateObject("Microsoft.SqlServer.NotificationServices.Subscription")
nsSubscription.Initialize (nsApplication), "**********Subscriptions"

' Set common properties for all subscribers
nsSubscription.SetFieldValue "DeviceName", "myDevice"
nsSubscription.SetFieldValue "SubscriberLocale", "en-us"
' Add subscriptions
nsSubscription.SubscriberId = "******"
nsSubscription.SetFieldValue "City", "*********"
nsSubscription.Add
nsSubscription.SubscriberId = "*****"
nsSubscription.SetFieldValue "City", "*********"
nsSubscription.Add
nsSubscription.SubscriberId = "***********"
nsSubscription.SetFieldValue "City", "*********"
nsSubscription.Add
wscript.echo "Subscriptions successfully added."
End Function

ERROR MESSAGE:
Line: 25
Char: 2
Error: Specified argument was out of range of valid values.
Parameter name: subscriptionClassName
Code: 80131502
Source: MicrosoftSqlServer.NotificationServices

any help will be much appreciated!

cheers,
Sunny

Hard to tell but it looks like you may have a typo in your subscription class name.

BTW - I recently blogged about deleting subscribers using VBScript; it's not exactly what you're trying to do, but perhaps it'll help.

http://sqlns.blogspot.com/2006/04/deleting-sqlns-v20-subscribers-using.html

And here's a link to a blog where I describe how to create subscribers, devices, and subscriptions in C#.

http://sqlns.blogspot.com/2005/09/creating-subscribers-in-v20.html

HTH..

Joe

adding subscriptions

Hi everyone,

Im not into VB scripting...On SSNS, im trying to add subscribers and subscriptions using VBscript.
I have been successful in adding subscribers but am getting an error while trying to add subscriptions... here's my code and the error:

PS: the tutorial code doesnt help much though it is very very similar, coz it is throwing up its own errors.

'
' AddSubscriptions.vbs
'
' Add a set of subscriptions to the ********** application
'
AddSubscriptions

Function AddSubscriptions()
Dim nsInstance, nsApplication, nsSubscription
' Create NSInstance object
Set nsInstance =
WScript.CreateObject("Microsoft.SqlServer.NotificationServices.NSInstance")
nsInstance.Initialize "*******"

' Create NSApplication object
Set nsApplication =
WScript.CreateObject("Microsoft.SqlServer.NotificationServices.NSApplication")
nsApplication.Initialize (nsInstance), "**********"
' Create NSSubscription object
Set nsSubscription =
WScript.CreateObject("Microsoft.SqlServer.NotificationServices.Subscription")
nsSubscription.Initialize (nsApplication), "**********Subscriptions"

' Set common properties for all subscribers
nsSubscription.SetFieldValue "DeviceName", "myDevice"
nsSubscription.SetFieldValue "SubscriberLocale", "en-us"
' Add subscriptions
nsSubscription.SubscriberId = "******"
nsSubscription.SetFieldValue "City", "*********"
nsSubscription.Add
nsSubscription.SubscriberId = "*****"
nsSubscription.SetFieldValue "City", "*********"
nsSubscription.Add
nsSubscription.SubscriberId = "***********"
nsSubscription.SetFieldValue "City", "*********"
nsSubscription.Add
wscript.echo "Subscriptions successfully added."
End Function

ERROR MESSAGE:
Line: 25
Char: 2
Error: Specified argument was out of range of valid values.
Parameter name: subscriptionClassName
Code: 80131502
Source: MicrosoftSqlServer.NotificationServices

any help will be much appreciated!

cheers,
Sunny

Hard to tell but it looks like you may have a typo in your subscription class name.

BTW - I recently blogged about deleting subscribers using VBScript; it's not exactly what you're trying to do, but perhaps it'll help.

http://sqlns.blogspot.com/2006/04/deleting-sqlns-v20-subscribers-using.html

And here's a link to a blog where I describe how to create subscribers, devices, and subscriptions in C#.

http://sqlns.blogspot.com/2005/09/creating-subscribers-in-v20.html

HTH..

Joe