SSRS中的VB表达导致错误

时间:2014-08-28 13:17:37

标签: sql sql-server visual-studio-2010 tsql reporting-services

我正在研究SSRS的表达式来改变背景单元格颜色。我一直收到错误在第二次IIF声明中,我不知道为什么,也许有人能发现我犯的错误?

这是我做的原始表达......哪个效果很好,

=IIF((Fields!DriveLetter.Value = "F:" OR Fields!DriveLetter.Value = "T:") AND (Fields!FileType.Value = "MDF" OR Fields!FileType.Value = "NDF"), "Lime",
IIF((Fields!DriveLetter.Value = "G:" OR Fields!DriveLetter.Value = "U:") AND (Fields!FileType.Value = "LDF"), "Lime", "Tomato") )

我添加了一个带有添加逻辑的IIF语句并导致错误。我一直在玩它,但无法得到错误。

=IIF((Fields!DriveLetter.Value = "F:" OR Fields!DriveLetter.Value = "T:") AND (Fields!FileType.Value = "MDF" OR Fields!FileType.Value = "NDF"), "Green",
 IIF(Fields!DriveLetter.Value = "G:" OR Fields!DriveLetter.Value = "U:") AND (Fields!FileType.Value = "LDF"), "Green",
 IIF(Fields!DriveLetter.Value = "C:") AND (Fields!Database_Name.Value = "master" OR Fields!Database_Name.Value = "model" OR Fields!Database_Name.Value = "msdb" 
                                                                                 OR Fields!Database_Name.Value = "tempdb"), "Lime", "Red" ) 

感谢。

1 个答案:

答案 0 :(得分:2)

钩子设置不正确:

IIF(((Fields!DriveLetter.Value = "F:" OR Fields!DriveLetter.Value = "T:") AND
(Fields!FileType.Value = "MDF" OR Fields!FileType.Value = "NDF")), "Green", 
IIF(((Fields!DriveLetter.Value = "G:" OR Fields!DriveLetter.Value = "U:") AND 
(Fields!FileType.Value = "LDF")), "Green", IIF(((Fields!DriveLetter.Value = "C:") AND 
(Fields!Database_Name.Value = "master" OR Fields!Database_Name.Value = "model" OR 
Fields!Database_Name.Value = "msdb" OR Fields!Database_Name.Value = "tempdb")), "Lime", 
"Red" )))