Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RS.exe subscribe report with parameters

I am trying to create dynamic report subscriptions through rs.exe. How ever I cannot get the parameters to work. The enddate value is data/time, so I think that might be causing it, but I do not know what to do about it. I have tried casting, but the error msg. stays the same.

rs.exe call:

C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn>rs.exe -i C:\Users\me\Desktop\rss_gen\subs.rss -s "localhost/ReportserverT"

subs.rss file:

Public Sub Main()
    rs.Credentials = System.Net.CredentialCache.DefaultCredentials

    Dim desc As String        = "Report description"
    Dim eventType As String   = "TimedSubscription"
    Dim scheduleXml As String = "<ScheduleDefinition><StartDateTime>2017-12-08T15:00:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Thursday>True</Thursday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
 Dim parameters() As ParameterValue


    ' If you need setup parameters

      Dim parameter As ParameterValue
        parameter.Name = "enddate"
        parameter.Value = "2017-12-30 10:03:01.250" 'this is date/time
    parameters(0) = parameter



    Dim matchData As String = scheduleXml


    Dim returnValue As String

    Dim reports() As String = { _ 
        "/My Folder/report"}

    For Each report As String In reports
        returnValue = rs.CreateSubscription(report, parameters)
        Console.WriteLine(returnValue)
    Next

End Sub 'Main`enter code here`

Error msg:

C:\Users\mee\AppData\Local\Temp\11\dhexge0m.1.vb(43) : error BC30455: Argument n ot specified for parameter 'Parameters' of 'Public Function CreateSubscription(R eport As String, ExtensionSettings As Microsoft.SqlServer.ReportingServices2005. ExtensionSettings, Description As String, EventType As String, MatchData As Stri ng, Parameters() As Microsoft.SqlServer.ReportingServices2005.ParameterValue) As String'.

like image 869
user1054844 Avatar asked Dec 08 '17 14:12

user1054844


People also ask

What are the two methods of delivery for report subscriptions?

Subscriptions in SSRS supports two types of Delivery options: Windows File Share, and Email.

How do I subscribe to SSRS report?

Browse the web portal of a report server (SSRS Native Mode). Navigate to the desired report. Right-click the report and select Subscribe.

What is Rs EXE utility in SSRS?

The SQL Server Reporting Services RS. EXE utility is a command line utility that can perform many scripted operation related to SQL Server Reporting Services (SSRS). It can be used to complete various administrative tasks including publishing reports and moving reports from one server to another server.

How do I run an RS EXE file?

RS.exe is located at \Program Files\Microsoft SQL Server\110\Tools\Binn. You can run the utility from any folder on your file system.


2 Answers

Let me teach you a trick to program in .Net and in general. It sounds simple, all you need to do is pass functions what they expect. Let me give you a simple example.

With this code I've got a similar error to you:

enter image description here

CS7036 There is no argument given that corresponds to the required formal parameter 'fileName' of 'FileInfo.FileInfo(string)'

The squiggle red line tells you where the problem is. If I type the opening bracket it will give me a tooltip with what it expects:

enter image description here

Ok it needs a string, so I declare a string and give it to the function as it expects:

enter image description here

So the problem you have is because you are not giving the CreateSubscription function the parameters it expects.

Argument not specified for parameter 'Parameters' of 'Public Function CreateSubscription

To fix it provide all the mandatory parameters to the ReportingService2005.CreateSubscription Method:

public static void Main()
   {
      ReportingService2005 rs = new ReportingService2005();
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

      string report = "/SampleReports/Employee Sales Summary";
      string desc = "Send email to [email protected]";
      string eventType = "TimedSubscription";
      string scheduleXml = @"<ScheduleDefinition><StartDateTime>2003-02-24T09:00:00-08:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>";

      ParameterValue[] extensionParams = new ParameterValue[8];

      extensionParams[0] = new ParameterValue();
      extensionParams[0].Name = "TO";
      extensionParams[0].Value = "[email protected]";

      extensionParams[1] = new ParameterValue();
      extensionParams[1].Name = "ReplyTo";
      extensionParams[1].Value = "[email protected]";

      ParameterValue parameter = new ParameterValue();
      parameter.Name = "EmpID";
      parameter.Value = "38";

      ParameterValue[] parameters = new ParameterValue[1];
      parameters[0] = parameter;

      string matchData = scheduleXml;
      ExtensionSettings extSettings = new ExtensionSettings();
      extSettings.ParameterValues = extensionParams;
      extSettings.Extension = "Report Server Email";

      try
      {
         rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters);
      }

      catch (SoapException e)
      {
         Console.WriteLine(e.Detail.InnerXml.ToString());
      }
   }
like image 163
Jeremy Thompson Avatar answered Sep 26 '22 02:09

Jeremy Thompson


As part of the 2005 report service for ms SQL, none of the parameters passed to CreateSubscription are optional. Please refer to the link and update the way you are calling the function. The error is clear, you are missing the parameters which is the last one. Look at the bottom of the page for an example.

https://technet.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsmanagementservice2005.reportingservice2005.createsubscription(v=sql.90).aspx

like image 24
Chillzy Avatar answered Sep 25 '22 02:09

Chillzy