How to: Add a Data-Bound Image (Reporting Services)
A report definition can include a reference to an image that is stored in a database. Such an image is known as a data-bound image. Add a data-bound image to the report body by dragging the Image report item from the Toolbox to the design surface, as you would for any report item. Adding a data-bound image to a page header or page footer requires additional steps. For more information, see Adding Page Headers and Footers.
If you created or stored the image in Microsoft Access, the image includes OLE header information that prevents the image from displaying on the report page at run time. You can remove the OLE header by using the second procedure below.
To add a data-bound image
In Design view, click Image in the Toolbox.
On the design surface, click the design surface and then drag the mouse to create a box that is the size of the desired image. Alternatively, click the design surface to create an image item of fixed size.
In the Image Properties dialog box type a name in the Name text box, or accept the default.
(Optional) In the Tooltip text box, type text to display when the user hovers the mouse over the image in the rendered report.
In Select the image source, select Database.
In Use this Field, select the field that contains the image.
In Use this MIME type, select the MIME type of the image.
Click OK.
An image placeholder appears on the report design surface.
To remove the OLE header from an Access image
Add an image from an Access data source as described in the previous procedure.
In the Image Properties dialog box, click the expression (fx) button.
In the Expression dialog box, copy the following expression, with no line breaks, into the expression pane:
=System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!ImageFieldName.Value),105))
The expression uses Mid to exclude the header information, which resides in the first 105 characters of the file, and then uses Convert to make the rest of the image base64 encoded. The expression assumes that the image originates in an EN-US database. If you are using a different collation, the OLE header might be longer or shorter than 105 characters.
Click OK twice.
An image placeholder appears on the report design surface.
See Also