7

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'.

user1054844
  • 922
  • 5
  • 17
  • 34
  • Please change VBA tag to VB.NET. – Kostas K. Dec 08 '17 at 15:42
  • If your `rs.CreateSubscription` is starting a new process, one possible problem could be the spaces in command arguments that you are passing to the new process. command args will remove everything after the 1st space. Anyway, need to see your `rs.CreateSubscription` function to be sure – Ibrahim D. Dec 11 '17 at 08:26
  • rs.CreateSubscription is built in function for Reporting Server https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.createsubscription.aspx – user1054844 Dec 11 '17 at 09:12

2 Answers2

3

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 anyone@microsoft.com";
      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 = "dank@adventure-works.com";

      extensionParams[1] = new ParameterValue();
      extensionParams[1].Name = "ReplyTo";
      extensionParams[1].Value = "reporting@adventure-works.com";

      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());
      }
   }
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
1

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

Chillzy
  • 468
  • 3
  • 9