Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Managing Report Subscriptions via VB Code

Author  Topic 

paulkem
Starting Member

28 Posts

Posted - 2013-11-13 : 14:03:32
I am trying to create a report subscription on the fly, then fire the subscription, then delete the subscription immediately after. I have the first two steps figured out, but what I have realized is that if you don't give the report time to execute, it will get deleted first. I threw in a Sleep just to give the report I am testing time to run. But since this execution time varies immensely, i need something more reliable. Is there a way to check to see if the subscription is running, or has just finished, before deleting the subscription? The core of my code looks something like this:


Dim NewSubID As String = rs.CreateSubscription(rptName, extSettings, rptDesc, eventType, matchData, Nothing)

Dim MySubs As Subscription() = rs.ListSubscriptions(rptName)

For Each SubX As Subscription In MySubs
If SubX.SubscriptionID = NewSubID Then
rs.FireEvent(SubX.EventType, SubX.SubscriptionID, Nothing)
Threading.Thread.Sleep(20000)
rs.DeleteSubscription(SubX.SubscriptionID)
End If
Next

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-11-13 : 17:36:19
There lis a RunningJobs table that you might find useful. Also, a stored proc - ListRunningJobs.
Go to Top of Page

paulkem
Starting Member

28 Posts

Posted - 2013-11-14 : 07:49:43
I do not believe I have access to that table. Is there any other way?
Go to Top of Page
   

- Advertisement -