我正在尝试使用Web Reference CreateSubscription方法通过C#代码创建报表订阅。我试过了:
我得到的错误是:
" System.Web.Services.Protocols.SoapException:报表服务器 无法打开与报表服务器数据库的连接"。
我现在有点卡住了。我不确定SSRS配置是否正确,或者我打电话时需要通过C#传递某些凭据。有什么想法吗?
使用的资源:
网络参考网址:
代码:
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string report = "/Demo/DemoReport";
string desc = "Send email";
string eventType = "TimedSubscription";
string scheduleXml = @"<ScheduleDefinition><StartDateTime>2017-11-
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 = "demo@demo.com";
extensionParams[1] = new ParameterValue();
extensionParams[1].Name = "ReplyTo";
extensionParams[1].Value = "demo@demo.com";
extensionParams[2] = new ParameterValue();
extensionParams[2].Name = "IncludeReport";
extensionParams[2].Value = "True";
extensionParams[3] = new ParameterValue();
extensionParams[3].Name = "RenderFormat";
extensionParams[3].Value = "MHTML";
extensionParams[4] = new ParameterValue();
extensionParams[4].Name = "Subject";
extensionParams[4].Value = "@ReportName was executed at
@ExecutionTime";
extensionParams[5] = new ParameterValue();
extensionParams[5].Name = "Comment";
extensionParams[5].Value = "Demo";
extensionParams[6] = new ParameterValue();
extensionParams[6].Name = "IncludeLink";
extensionParams[6].Value = "True";
extensionParams[7] = new ParameterValue();
extensionParams[7].Name = "Priority";
extensionParams[7].Value = "NORMAL";
ParameterValue parameter = new ParameterValue();
parameter.Name = "";
parameter.Value = "";
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());
}
错误:
System.Web.Services.Protocols.SoapException:报表服务器不能 打开与报表服务器数据库的连接。与...的连接 所有请求和处理都需要数据库。 ---&GT; Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException: 报表服务器无法打开与报表服务器的连接 数据库。所有请求都需要与数据库建立连接 和处理。在 Microsoft.ReportingServices.Library.Global.EnsureModeFromCatalog()
在Microsoft.ReportingServices.Library.Global.EnsureRSNativeMode()
在Microsoft.ReportingServices.WebServer.ReportingService2005..ctor()