我正在尝试通过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):错误BC30455: 参数&#39;参数&#39;指定的参数公共职能部门 CreateSubscription(R eport As String,ExtensionSettings As Microsoft.SqlServer.ReportingServices2005。 ExtensionSettings, 描述为String,EventType为String,MatchData As Stri ng, 参数()为 Microsoft.SqlServer.ReportingServices2005.ParameterValue)As String&#39;。
答案 0 :(得分:3)
让我教你一个在.Net中编程的技巧。这听起来很简单,你需要做的就是传递他们期望的功能。让我举个简单的例子。
使用此代码我遇到了类似的错误:
CS7036没有给出的参数对应于'FileInfo.FileInfo(string)'
所需的形式参数'fileName'
红色波浪线告诉您问题所在。如果我输入左括号,它会给我一个预期的工具提示:
好的,它需要一个字符串,所以我声明一个字符串,并按预期将它提供给函数:
所以你遇到的问题是因为你没有给CreateSubscription
函数提供它期望的参数。
未为'Public Function CreateSubscription
的参数'Parameters'指定参数
要修复它,请为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());
}
}
答案 1 :(得分:1)
作为2005 SQL报告服务的一部分,传递给CreateSubscription的参数都不是可选的。请参阅链接并更新您调用该功能的方式。错误很明显,您缺少最后一个参数。请查看页面底部的示例。