ASP.NET ReportViewer 服务器报表渲染流导致异常
我尝试使用 ASP.NET ReportViewer (2008 SP1) 中的 ServerReport.RenderStream
方法,但该方法出现 rsStreamNotFound
异常。设置参数后,我尝试了下面两行不同的代码。我正在与 SQL Server 2005 和 SSRS 2005 进行交互。我已经看过有关此问题的修补程序的文章,但我真的不想诉诸修补程序,因为我不确定 IT 是否会接受它我没有找到太多关于该错误的文档
找不到该流。溪流 提供给一个标识符 操作不能位于 报表服务器数据库.报表服务器数据库。
准备代码:
string mimeType;
string encoding;
List<ReportParameter> parameters = new List<ReportParameter>();
string startDateValue = Request.Form[startDate.UniqueID];
string endDateValue = Request.Form[endDate.UniqueID];
parameters.Add(new ReportParameter("Owner", "5", false));
parameters.Add(new ReportParameter("StartDate", startDateValue, false));
parameters.Add(new ReportParameter("EndDate", endDateValue, false));
ReportViewer1.ServerReport.SetParameters(parameters);
通话 1:
byte[] result = ReportViewer1.ServerReport.RenderStream("PDF", string.Empty, string.Empty, out mimeType, out encoding);
通话 2:
byte[] result = ReportViewer1.ServerReport.RenderStream("CSV", string.Empty, string.Empty, out mimeType, out encoding);
清理:
Response.Clear();
Response.ContentType = mimeType;
Response.ContentEncoding = System.Text.Encoding.GetEncoding(encoding);
Response.OutputStream.Write(result, 0, result.Length);
对解决方案有什么想法吗?最终目标是将其写入 CSV 以供下载。实际上,我很乐意将 XML 转换为 CSV.report 服务器数据库。
I'm trying to use the ServerReport.RenderStream
method from the ASP.NET ReportViewer (2008 SP1), but I'm getting a rsStreamNotFound
exception from the method. I've tried the two different lines of code below after setting the parameters. I'm interfacing with SQL Server 2005 and SSRS 2005. I've seen articles about a hotfix for this issue, but I'd really rather not resort to a hotfix, as I'm not sure that IT will be OK with it going in. There isn't too much documentation that I've found on the error which is
The stream cannot be found. The stream
identifier that is provided to an
operation cannot be located in the
report server database.report server database.
Prep Code:
string mimeType;
string encoding;
List<ReportParameter> parameters = new List<ReportParameter>();
string startDateValue = Request.Form[startDate.UniqueID];
string endDateValue = Request.Form[endDate.UniqueID];
parameters.Add(new ReportParameter("Owner", "5", false));
parameters.Add(new ReportParameter("StartDate", startDateValue, false));
parameters.Add(new ReportParameter("EndDate", endDateValue, false));
ReportViewer1.ServerReport.SetParameters(parameters);
Call 1:
byte[] result = ReportViewer1.ServerReport.RenderStream("PDF", string.Empty, string.Empty, out mimeType, out encoding);
Call 2:
byte[] result = ReportViewer1.ServerReport.RenderStream("CSV", string.Empty, string.Empty, out mimeType, out encoding);
Clean up:
Response.Clear();
Response.ContentType = mimeType;
Response.ContentEncoding = System.Text.Encoding.GetEncoding(encoding);
Response.OutputStream.Write(result, 0, result.Length);
Any thoughts on a solution? The end goal is to write this out to CSV for a download. In reality I'd be happy with XML that I'd translate to CSV.report server database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
渲染流< /a> 用于获取现有 Stream 并以不同的方式处理它或渲染外部资源,因此
Render
正是您一直需要的。RenderStream
的 C# 签名是第二个参数
streamId
,是现有 Stream 的 ID;您正在传递String.Empty
,因此会出现找不到标识符的错误消息。您可以从 Render() 方法:这个问题更多地涉及使用 Render 和 RenderStream。
(我意识到这个问题已经有一年了,但我想我应该将我发现的内容发布给其他偶然发现它的人。)
RenderStream is used to take an existing Stream and process it in a different manner or render external resources, so
Render
was what you needed all along. The C# signature ofRenderStream
isThe second parameter,
streamId
, is the ID of an existing Stream; you were passingString.Empty
, hence the error message of not finding the identifier. You can get the StreamID(s) without string[] streams
from one of the Render() methods:This question deals more with using Render and RenderStream.
(I realize the question is a year old, but I thought I'd post what I found for anyone else who stumbles upon it.)
是的,Render 方法正是我想要的。不过,我很想听听有 RenderStream 经验的人的意见。
Yep, the Render method does exactly what I want it to do. I'd love to hear from someone that has experience on RenderStream though.