vb.net – 带参数的RS.exe订阅报告

前端之家收集整理的这篇文章主要介绍了vb.net – 带参数的RS.exe订阅报告前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图通过rs.exe创建动态报表订阅.我怎么不能让参数工作. enddate值是数据/时间,所以我认为这可能会导致它,但我不知道如何处理它.我已经尝试过施法,但错误信息.保持不变.

rs.exe调用

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文件

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\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’.

让我教你一个在.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());
      }
   }

猜你在找的VB相关文章