(rewrote of the problem)
I have trouble to display an image in the footer. The issue is, I try to convert an image from the DB to a Base64 String. In case of get an image is is working, but if in the db is a null value the Textfield displays #ERROR.
IIF(IsNothing(Fields!Company_Picture.Value), "", Convert.ToBase64String(Fields!Company_Picture.Value))
I expected the else tree isn't executed in the case of IsNothing = True. But in the Report the TextField displays always #ERROR, if there is no image.
Solution is:
Public Function Base64String(ByVal img() as byte)
if not isNothing(img) then
Return Convert.ToBase64String(img)
end if
Return ""
end function
Thanks to all :-)
--- first try to cover my problem but it don't hit the main problem exact enougt ---
I have in the Report Code part Shared Data1 as Object
Public Function GetData(Num as Integer, Group as integer) as Object
if Group = 1 then
Return Cstr(Choose(Num, Split(Cstr(Data1),Chr(177))))
End If
End
and the same to set the data.
In the DB I have a image stored as blob. The direct displaying in the Report is working. Now I have to show the image in footer of the report. I have made a Table and inside of one cell I use the hidden Expression to insert the Image to the object.
Here is now the issue. I try to make it with
Code.SetData(IIF(IsNothing(First(Fields!CompanyPicture.Value, "DataSet_Result")) = TRUE, "", Convert.ToBase64String(Fields!CompanyPicture.Value) + Chr(177), 1)
The report crashes now on this expression, because the Hidden Expression can't be NULL. I do not understand, why from the IIF the else tree is executed. The IsNothing works correct and gives me True.
Any ideas what I can do, if the Image is Null?
As well as the comments in @Schlaagi's answer. IIF always evaluates both the true and false outcome so it will fail unless you accommodate this properly.
I don't know what the SetData function does and it's been a while since I've used Convert.ToBase64String but have a look at this and see if it makes sense.
=Code.SetData(
Convert.ToBase64String(
IIF(IsNothing(Fields!CompanyPicture.Value, "DataSet_Result"),
"",
Fields!CompanyPicture.Value + Chr(177))
)
, 1
)