调试 SSRS 的最佳策略是什么?
我正在寻找方法来追踪 SSRS 错误发生的位置。
我有一份大约 90 列宽的报告,其中包含多个公式。 我遇到的问题是其中一个公式存在除以零的错误。 我已经在这个 问题,但我仍然收到错误。 我知道答案是有效的,因为我已经在一份小报告上测试过它。
所以问题是:当 SSRS 只报告发生错误时,您到底如何确定 SSRS 中发生错误的位置?
编辑 显示的错误是
本地报表处理期间发生错误
报表处理期间发生错误
无法读取数据集 MainReport 的下一个数据行
遇到除以零错误
I am looking for ways to track down where an SSRS error is occuring.
I have a report that is about 90 columns wide with multiple formulas. The problem that I am having is that on one of the formulas there is a divide by Zero error. I have implemented the answer from Robert Harvey in this question but I still get the error. I know that the answer works as I have tested it on a small report.
So the question is: How on earth do you identify where an error is occuring in SSRS when SSRS only reports that an error occured?
EDIT The error as displayed is
An error occured during local report processing
An error has occoured during report processing
Cannot read next data row for the dataset MainReport
Divide By Zero error encounted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
跟进
问题最终出在 SQL 查询上。 作为 SQL 查询的一部分,我有如下所示的 In 子句。
SSRS 使用 exec sp_executesql 和 string.replace 将 ID 注入 IN 子句。
我遇到的问题是我将在 SQL Studio Manager 中运行查询。 输入所有变量后,它将按预期工作。 但在 SSRS 下,它会因除以零错误而失败,并且没有真正明确的指示错误发生的位置。
在我复制了一份报告并逐一删除了项目,直到报告上几乎没有任何内容可供渲染并且仍然产生错误后,我将注意力转向 SQL 查询。
正是在那里发生了错误。 我是在使用 SQL Profiler 找出 SSRS 实际运行的内容后才发现它的。
之后,删除有问题的行并返回划分的单独部分并通过 RSolberg 建议的函数运行它是相对容易的修复。
Follow Up
The problem ended up being the SQL Query. As part of the SQL query, I had as In clause like the following.
SSRS uses
exec sp_executesql
and string.replace to inject the ID's into the IN clause.The problem I had was I would run the query in SQL Studio Manager. with all the variables entered and it would work as expected. but under SSRS it would fail with the divide by Zero error, and there was no real clear indication where the error occured.
After I made a copy of the report and deleted items one by one until there was litrally nothing left on the report to render and it still produced the error, I turned my attention to the SQL Query.
It was there that error was occuring. I only found it after using SQL Profiler to find out what SSRS was actually running.
After that it was relativly easy fix of deleting the offending line and returning the seperate parts of the divide and run it through the function that RSolberg suggested.
编辑
我建议不要使用 IIF 语句和其他语句,而是执行以下操作...将自定义函数添加到报告中,转到报告属性和代码选项卡。 创建以下内容。 要具体识别引发错误的字段,您可以更改它以返回一个字符串,也许返回“#OOOOOOPS”,以便它在报告中突出显示。
添加此函数后,转到表达式视图,查找将发生除法的所有字段。 您可以通过输入以下内容来执行这个新创建的函数:
ORIGINAL
如果您在 Visual Studio 中运行报告,它是否会告诉您计算失败的特定文本框/标签/字段? 这应该有助于查明问题的根源,但您也可以通过查看下面的代码来确保您永远不会执行分母为 0 的除法...
EDIT
Rather than use the IIF statements and others, I'd reccomend doing the following... Add a custom function to your report, go to report properties and the code tab. Create the following. To specifically identify the field that is throwing the error, you can change this to return a string and maybe "#OOOOOOPS" so it sticks out on the report.
After adding this function, go to the expression view for all of the fields that you have where division will occur. You can execute this newly created function by typing in:
ORIGINAL
If you run the report within visual studio, does it tell you which specific textbox/label/field the computation failed in? That should help pinpoint where the issue is coming from, but you could also make sure that you never perform the division with 0 in the denominator by looking at the code below...