问题
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.
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"
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!")
this always returns False, even if the image exists.
I even tried using some custom code I found here.
Code:
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!")
But this also always just returns false.
回答1:
ok, I needed this thanks.
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.
来源:https://stackoverflow.com/questions/26433023/ssrs-2008-r2-check-if-external-image-exists-on-report-server