SSRS 2008 R2 检查报表服务器上是否存在外部图像
我正在处理 SSRS 2008 R2 报告,并且正在动态显示图像.如果图像在我们的报表服务器上不存在,我想隐藏图像框并显示一个带有文本的图标,上面写着找不到图像".
I'm working on an SSRS 2008 R2 report and I'm displaying images dynamically. I would like to hide the image box and display an icon with text that reads "Image not found" if the image doesn't exist on our report server.
我已经尝试了一些关于表达式的方法,但我无法根据图像是否存在让它们正确返回 true 或 false.
I've tried a few things with expressions, but I can't get them to correctly return true or false, based on if the image exists or not.
我用来显示图像的表达式是:
The expression I'm using to display the image is:
="/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"
为了测试我是否可以让报告检测图像是否存在,我将一个文本框拖到我的报告上并尝试了以下表达式以尝试返回 True
或 False代码>.
To test if I could get the report to detect whether the image existed, I dragged a textbox onto my report and tried the following expressions in an attempt to return True
or False
.
=IIf(IsNothing("/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"), "Woohoo!", "Do'h!")
这总是返回 False,即使图像存在.
=IIf(IsNothing("/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"), "Woohoo!", "Do'h!")
this always returns False, even if the image exists.
我什至尝试使用我发现的一些自定义代码 这里.
I even tried using some custom code I found here.
代码:
Function IsValid(ByVal Url As String) As Boolean
Dim sStream As IO.Stream
Dim URLReq As Net.HttpWebRequest
Dim URLRes As Net.HttpWebResponse
Try
URLReq = Net.WebRequest.Create(Url)
URLReq.Credentials = System.Net.CredentialCache.DefaultCredentials
URLRes = URLReq.GetResponse()
sStream = URLRes.GetResponseStream()
Dim reader As String = New IO.StreamReader(sStream).ReadToEnd()
Return True
Catch ex As Exception
Return False
End Try
End Function
我用于该代码的表达式是:
And the expression I used for that code is:
=IIf(Code.IsValid("/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"), "Woohoo!", "Do'h!")
但这也总是只返回 false.
But this also always just returns false.
好的,我需要这个,谢谢.
ok, I needed this thanks.
您的错误是您使用了网页 IsValue 的保留字.将您的函数名称更改为 IsThere,它应该可以正常工作.
Your error here is you are using a reserve word for a webpage IsValue. Change your function name to IsThere and it should work famously.