【问题标题】:Comments in SSRS Report ExpressionsSSRS 报告表达式中的注释
【发布时间】:2010-10-27 12:37:29
【问题描述】:

我在 Reporting Services 中使用了一些复杂的表达式来控制报告中数据的值、格式等(请参阅MSDN)。

是否可以在这些表达式中插入代码 cmets,如果可以,语法是什么?

代码 cmets 我的意思是:

// single line comment
/* or multi line comment */

【问题讨论】:

  • | & IIF(0, "评论...", "") & |是 /* 插入中间 */ 字符串注释的最佳解决方法。数值计算不走运,因为 IIF() 会评估所有参数。

标签: sql-server sql-server-2008 reporting-services reporting ssrs-2008


【解决方案1】:

它看起来像 VB 代码。
尝试使用撇号写评论。

'This is a sample comment.

这是一个猜测:)

编辑:VB 并没有真正的多行注释。
但是,请尝试使用以下方法看看它是否有效

'This is a sample comment _ followed by a new line _ and the comment ends

如果这不起作用,你可以这样做


'This is a sample comment
'followed by a new line
'and the comment ends

EDIT2:另外,评论似乎应该放在最后。

【讨论】:

  • 谢谢 :) 我试过了。该语法似乎仅在表达式的末尾起作用-从您的链接中可以理解,无法评论中间表达式,因为它被处理为一行。如果我在表达式的开头使用它,表达式代码就变成了报表输出,不好!
  • 嗯。多行注释是否按预期工作(使用下划线)?
  • 实际上没有必要,因为第一个 ' 之后的所有行都被视为注释的一部分。但是,代码突出显示无法识别多余的行(带或不带下划线)。
  • 在 SQL Server Reporting Services 2008 R2、Report Builder 3.0 应用程序中,这对我有用。我在表达式的末尾添加了一条注释,并用单引号将其分隔。
  • 是的。 ' 语法非常适合在 SSRS 表达式中进行注释。如果您想进一步阅读...MidnightDBA: Commenting SSRS。语言是 Visual Basic,您可以在此处阅读更多信息 MSDocs: Reporting Services Code and Assembly references in Expressions
【解决方案2】:

如果你想评论一个 switch 语句,你可以这样做:

=switch(
   false, "--- First, test if above zero ---"
   , Parameters!Test.Value > 0
   , "Value is above zero. Yeah!"

   , false, "--- Then test if -1 ---"
   , Parameters!Test.Value = -1
   , "I guess the value is unknown"

   , false, "--- Finally catch everything else ---"
   , true
   , "We could not handle this value. Sorry :-\"
)

永远不会命中带有 false 的行,这样您就可以将它们用作注释。不是很漂亮但很有用:-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多