Eon*_*Eon 5 vb.net custom-code reporting-services
部署报告时,SSRS会生成以下错误:
自定义代码的第58行出现错误:[BC30201]预期表达式
但是,该报告在预览模式下正常工作并正确显示该字段.
这里的自定义代码段也在visual studio中编写和测试.
这是自定义代码:
If (evaluationDate.Day = 31) Then '* affected line
returnValue.Append(String.Format("{0}{1:dd.MM}{2}", _
If(index = 2, " und ", String.Empty), _
New DateTime(evaluationDate.Year, evaluationDate.Month, lastDayOfMonthDictionary(evaluationDate.Month)), _
If(index = 2, ".", String.Empty)))
End If
Run Code Online (Sandbox Code Playgroud)
如您所见,问题出在IF..THEN块上.evaluationDate的类型为DateTime,该值等于DateTime参数startdate或提前六个月startDate- 这是函数签名中的datetime参数.
我不明白这有什么问题,我需要知道我能做些什么来解决这个问题.有任何想法吗?
结论 - SSRS有一种处理三元的邪恶方法,尽管它完全期望自定义代码段中的VB代码.
我收到的这个错误是错误的指向,甚至指向错误的行 - 这是我在问题中标记的这一行的正下方.
注意If(index = 2, " und ", String.Empty)三元的用法:- SSRS尝试运行If-ternary(就像你在VB.NET中声明的那样)作为一个If..Then块 - 因为没有Then找到,并且有多个参数以逗号分隔,这会混淆SSRS,从而它打印Expression Expected
解决此问题的方法是传统的SSRS表达方式
'Instead of this:
If(index = 2, " und ", String.Empty)
'Use This:
IIf(index = 2, " und ", String.Empty)
Run Code Online (Sandbox Code Playgroud)
这应该仍然允许您预览代码(即使正常If允许您预览,但在部署期间中断)
| 归档时间: |
|
| 查看次数: |
3814 次 |
| 最近记录: |