调试SSRS的最佳策略是什么?

Nat*_*her 3 bug-tracking reporting-services

我正在寻找方法来追踪SSRS错误发生的位置.

我有一个大约90列宽的报告,包含多个公式.我遇到的问题是,在其中一个公式中存在除零误差.我已经在这个问题中实现了Robert Harvey的答案,但我仍然得到错误.我知道答案是有效的,因为我在一份小报告中对其进行了测试.

所以问题是:当SSRS仅报告发生错误时,您究竟如何确定SSRS中发生错误的位置?

编辑显示的错误是

本地报告处理期间发生错误报告处理期间
出现错误
无法读取数据集的下一个数据行MainReport
Divide By Zero错误已装入

RSo*_*erg 6

编辑
而不是使用IIF语句和其他语句,我建议执行以下操作...在报表中添加自定义函数,转到报表属性和代码选项卡.创建以下内容.要专门识别引发错误的字段,您可以更改此字符串以返回字符串,并且可能是"#OOOOOOPS",因此它会突出显示报告.

Public Function SafeDivision(ByVal top As Decimal, ByVal bottom As Decimal) As Decimal
   If bottom = 0 Then
      Return 0
      Else : Return top / bottom
   End If
End Function
Run Code Online (Sandbox Code Playgroud)

添加此函数后,转到表达式视图,查看将要进行除法的所有字段.您可以通过键入以下内容来执行此新创建的功能:

=Code.SafeDivivision(CDbl(1.24), CDbl(0))
Run Code Online (Sandbox Code Playgroud)

原始
如果您在visual studio中运行报告,它是否告诉您计算失败的特定文本框/标签/字段?这应该有助于确定问题的来源,但你也可以通过查看下面的代码确保你永远不会在分母中使用0进行除法...

//myBottom would be the value of the denominator 
//myTop would be the value of the numerator 

= IIF(myBottom <> 0, myTop / myBottom, "")
Run Code Online (Sandbox Code Playgroud)