I'm trying to generate a report using C# and a RDL file. I have followed examples but I can't get it going. I get the error:
我正在尝试使用C#和RDL文件生成报告。我已经按照例子,但我无法得到它。我收到错误:
"The path of the item 'sample.rdl' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash. (rsInvalidItemPath)". I have tried prepending a slash to the path with no success.
“项目'sample.rdl'的路径无效。完整路径长度必须少于260个字符;其他限制适用。如果报表服务器处于纯模式,则路径必须以斜杠开头。(rsInvalidItemPath)” 。我试过在路径上加上一个斜线而没有成功。
My Reporting Server is in Native mode. My two main questions are:
我的报告服务器处于纯模式。我的两个主要问题是:
- Do I need parameters?
- 我需要参数吗?
- Where should my RDL file be stored?
- 我的RDL文件应该存储在哪里?
Right now I am storing my RDL file within my project. (I don't think this is right)
现在我将我的RDL文件存储在我的项目中。 (我认为这不对)
Here's a code snippet:
这是一段代码:
const string path = "sample.rdl";
string url = "http://localhost/ReportServer";
string format = "PDF";
var rsReports = new Microsoft.Reporting.WebForms.ReportViewer
{
ProcessingMode = ProcessingMode.Remote,
ShowParameterPrompts = false
};
rsReports.ServerReport.ReportServerUrl = new Uri(url);
rsReports.ServerReport.ReportPath = Path.Combine("\\" + Environment.CurrentDirectory, path);
rsReports.ServerReport.Refresh();
byte[] report = rsReports.ServerReport.Render(format.ToUpper());
return report;
1 个解决方案
#1
1
Your RDL file must be deployed to the SSRS server. You can do that from within Visual Studio. Right click on your report project and set the report server url to http://localhost/ReportServer.
您的RDL文件必须部署到SSRS服务器。您可以在Visual Studio中执行此操作。右键单击报表项目,将报表服务器URL设置为http:// localhost / ReportServer。
Then right click on your report and select deploy. That will deploy your report and data sources to the server.
然后右键单击您的报告并选择部署。这会将您的报告和数据源部署到服务器。
You can then try your code again, after you change this line....
然后,您可以在更改此行后再次尝试代码....
rsReports.ServerReport.ReportPath = "/folder/reportName";
Where folder is the name of the folder on the server where the report was published to, and reportName = "sample" (whithout the .rdl)
其中folder是发布报表的服务器上文件夹的名称,reportName =“sample”(不包括.rdl)
The error your're getting means the path must start with a '/'
你得到的错误意味着路径必须以'/'开头
#1
1
Your RDL file must be deployed to the SSRS server. You can do that from within Visual Studio. Right click on your report project and set the report server url to http://localhost/ReportServer.
您的RDL文件必须部署到SSRS服务器。您可以在Visual Studio中执行此操作。右键单击报表项目,将报表服务器URL设置为http:// localhost / ReportServer。
Then right click on your report and select deploy. That will deploy your report and data sources to the server.
然后右键单击您的报告并选择部署。这会将您的报告和数据源部署到服务器。
You can then try your code again, after you change this line....
然后,您可以在更改此行后再次尝试代码....
rsReports.ServerReport.ReportPath = "/folder/reportName";
Where folder is the name of the folder on the server where the report was published to, and reportName = "sample" (whithout the .rdl)
其中folder是发布报表的服务器上文件夹的名称,reportName =“sample”(不包括.rdl)
The error your're getting means the path must start with a '/'
你得到的错误意味着路径必须以'/'开头