使用 SQL Server Reporting Services 将数据集传递到子报表
我正在使用 SQL Server Reporting Services 和 Visual Studio 附带的报表设计器。 我收到了一份非常大的报告。 它实际上太大了,以至于当我进行更改时,Visual Studio 会挂起(有时一次长达数小时)或崩溃。
我无能为力解决这个问题,所以我决定将报告的下半部分移到子报告中。 因此,我从一份巨大的、反应迟钝的报告开始,以两份小的、易于管理的报告结束——令人惊讶的是,这确实有效。
一个问题:我的子报告使用与主报告相同的数据。 现在,它通过重新查询数据库来填充其数据集。 与数据库的额外往返导致生成报告的时间增加一倍; 生成时间从 45 分钟缩短到 1 1/2 小时。
我想避免再次访问数据库,而是在两个报告中使用相同的数据集。
如何在报表和子报表之间共享或传递数据集?
I'm using SQL Server Reporting Services and the report designer that comes with Visual Studio. I've got a really big report. It's actually so large that Visual Studio hangs (sometimes for hours at a time) or just crashes when I make changes.
There is preciously little I can do to solve the problem, so I've decided to just move the bottom half of the report into a sub-report. So, I started with one enormous, unresponsive report and ended with two small, manageable reports -- surprisingly, this actually works.
One problem: my subreport uses the same data as my main report. Right now, it populates its dataset by re-querying the database. The extra round-trip to the database causes the report to take twice as long to generate; up from 45 minutes to 1 1/2 hours to generate.
I'd like to avoid hitting the database again, and instead use the same dataset in both reports.
How can I share or pass a dataset between a report and subreport?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用虚拟参数来完成此操作:
i。 在主报告“MyData”中创建一个参数并勾选“内部”
ii。 将“MyData”的默认值设置为您的数据集
iii. 。 使用表达式设置子报告参数
希望这有帮助,
邓肯
You can do it using a dummy parameter:
i. Create a parameter in your main report 'MyData' and tick 'internal'
ii. Set default value of 'MyData' to your data-set
iii. Set the sub-report parameter with the expression
Hope this helps,
Duncan
如果创建表格,则可以合并详细信息行的所有单元格并将子报表作为内容。 然后将子报表的参数设置为要运行子报表的字段。
贾森
If you create a table, you can merge all the cells of the details row and put a subreport as the contents. Then set the parameter of the subreport to the field you want to run the subreport against.
Jason
我认为这可以帮助你:
http://www.gotreportviewer.com/subreports/index.html
I think this can help you:
http://www.gotreportviewer.com/subreports/index.html
我很确定你不能。 您可能最好寻找完全重新设计报表的方法,使其不那么大......更不用说导出到 Excel 时子报表的各种问题了。
I'm pretty sure you can't. You're probably better off looking for ways to redesign the report entirely so that it's not so large... not to mention the various problems with subreports when exporting to excel.
我有几份报告称 SQL 非常复杂,当我尝试编辑它时,它会锁定 Visual Studio。 在这些报告中,我直接进入代码视图并直接编辑 XML,这很有效。 当 Visual Studio 神秘地使列比我设置的稍宽时,我也会这样做。 但是,我怀疑如果您对报告布局的编辑过多,您是否愿意走这条路。
是否可以使用两个报告都使用的存储过程来构建表,而不是在报告中运行查询? 第一个报告运行存储过程来构建表,然后两个报告只需查询该报告。 如果报表可由多个用户运行,请注意并发问题。
I have several reports that the SQL is so complex in that it locks up Visual Studio when I try to edit it. In these reports I go straight into the Code view and edit the XML directly, which works. I also do this when Visual Studio mysteriously makes columns slightly wider than I set them at. However, I doubt you'd want to go down this path if you are editing the layout of the report too much.
Instead of running your query in the report, would it be possible to build a table using a stored procedure that both reports use? The first report runs the stored procedure to build the table and then both reports simply query the report. Watch for concurrency problems if the report can be run by multiple users.
您是否尝试过在列表中使用列表,其中两个列表使用相同的数据集,然后过滤内部列表以仅显示链接到外部列表的记录?
就执行时间而言,45 分钟一开始就显得很长。 我假设您已经对执行计划进行了一些分析,以验证您的查询或存储过程是否使用有意义的索引?
希望这有帮助,
比尔
Have you tried using a list within a list where both lists use the same dataset and then filter the inner list to display only records linked to the the outer list?
As far as the execution time, 45 minutes seems like an awful long time in the first place. I'm assuming you've done some analysis of the execution plan to verify your query or stored procedure is using meaningful indexes?
Hope this helps,
Bill