C# 如何使用报告查看器从 asp 网页打开 ssrs 报告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12607920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to open ssrs report from asp web page using report viewer
提问by Rick
I'm trying to open an ssrs report on my web pages using ReportViewer. For the Report Serverl URL I have:
我正在尝试使用 ReportViewer 在我的网页上打开 ssrs 报告。对于 Report Serverl URL,我有:
http://db_servers/ReportsServer_SENSORSQLSERVER
and for my report path I have:
对于我的报告路径,我有:
http://db_servers/ReportsServer_SENSORSQLSERVER/Pages/ReportViewer.aspx?%2fCustomer1&rs:Command=Render.
I have looked through many sites and tutorial on how to add URL but I still get an error saying: The length of my link must be below 260 characters long. (rsInvalidItemPath). I also want to mention that my report server is in Native mode. My report server is located in another computer so I made sure the processing mode on my report viewer is remote. Whenever I go to the surver url I can clearly see the list of my reports and when I click on a report I can see it as well so I know my urls are correct. I have tried including a slash in front of my report path url, replacing "2%f" with a space. Nothing seems to work. Any idea? Thanks.
我浏览了许多关于如何添加 URL 的网站和教程,但我仍然收到一条错误消息:我的链接长度必须低于 260 个字符。(rsInvalidItemPath)。我还想提一下,我的报表服务器处于本机模式。我的报表服务器位于另一台计算机上,因此我确保报表查看器上的处理模式是远程的。每当我转到 surver url 时,我都可以清楚地看到我的报告列表,当我点击报告时,我也可以看到它,所以我知道我的 url 是正确的。我试过在我的报告路径 url 前面包含一个斜杠,用空格替换“2%f”。似乎没有任何效果。任何的想法?谢谢。
采纳答案by Kevin LaBranche
You need to separate out the URL to the server, report path and add the parameters to a parameters array.
您需要分离出服务器的 URL、报告路径并将参数添加到参数数组中。
Here's a sample:
这是一个示例:
protected void Page_Init(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Set the processing mode for the ReportViewer to Remote
reportViewer.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = reportViewer.ServerReport;
// Set the report server URL and report path
serverReport.ReportServerUrl =
new Uri("http://<Server Name>/reportserver");
serverReport.ReportPath =
"/AdventureWorks Sample Reports/Sales Order Detail";
// Create the sales order number report parameter
ReportParameter salesOrderNumber = new ReportParameter();
salesOrderNumber.Name = "SalesOrderNumber";
salesOrderNumber.Values.Add("SO43661");
// Set the report parameters for the report
reportViewer.ServerReport.SetParameters(
new ReportParameter[] { salesOrderNumber });
}
}
Above taken from Using the WebForms ReportViewer Control.
回答by Daniel
You should replace the "2%f"by "/".
您应该替换"2%f"by "/"。
The problem is with your ReportPath property, e.g:
问题出在您的 ReportPath 属性上,例如:
%2fCustomer1-> /Customer1
%2fCustomer1-> /Customer1
回答by Dilip Oganiya
Very simple method to open SSRS :
打开 SSRS 的非常简单的方法:
string reportName = "TestReport";
string displayName = reportName;
bool isDomainAuthentication = false;
var reportParameters = new List<ReportParameter>();
reportParameters.AddRange((List<ReportParameter>)Session["ReportParameters"]);
string ReportServerURL = "http://DESKTOP38/ReportServer_SQLEXPRESS";
reportViewer1.ServerReport.ReportServerUrl = new Uri(ReportServerURL);
reportViewer1.ServerReport.ReportPath = "FolderName" + reportName;
reportViewer1.ServerReport.DisplayName = displayName;
reportViewer1.ShowPrintButton = true;
reportViewer1.ShowToolBar = true;
reportViewer1.ShowCredentialPrompts = false;
if (!isDomainAuthentication)
{
string userId = "DESKTOP38"; //Username
string password = "test";
string domain = ReportServerURL;
IReportServerCredentials reportCredentials = new ReportServerCredentials(userId, password, domain);
reportViewer1.ServerReport.ReportServerCredentials = reportCredentials;
}
if (reportParameters != null)
{
reportViewer1.ServerReport.SetParameters(reportParameters);
}
this.reportViewer1.ServerReport.Refresh();

