RS.exe 订阅带参数的报告

RS.exe subscribe report with parameters

我正在尝试通过 rs.exe 创建动态报告订阅。我怎么无法让参数工作。结束日期值为 data/time,所以我认为这可能是造成它的原因,但我不知道该怎么做。我试过投射,但错误消息。保持不变。

rs.exe 通话:

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

subs.rss 文件:

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`

错误消息:

C:\Users\mee\AppData\Local\Temp\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'.

作为 ms SQL 的 2005 报告服务的一部分,传递给 CreateSubscription 的参数 none 是可选的。请参考 link 并更新您调用函数的方式。错误很明显,您缺少最后一个参数。查看页面底部的示例。

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

让我教你一个在 .Net 和一般情况下编程的技巧。这听起来很简单,您需要做的就是传递他们期望的函数。举个简单的例子。

使用这段代码,我遇到了与您类似的错误:

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

红色波浪线告诉您问题出在哪里。如果我输入左括号,它会给我一个工具提示,其中包含 它期望的内容 :

好的,它需要一个字符串,所以我声明了一个字符串,并按预期将其提供给函数:

所以你遇到的问题是因为你没有给 CreateSubscription 函数它期望的参数。

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

要修复它,请向 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());
      }
   }