RDLC + ReportViewer Control – how to display images from the database

imagerdlcreportviewer

I am storing GIF images (I can switch to BMP if necessary) in a varbinary column in SQL 2008. I want to display these images in a PDF rendered by the ReportViewer control from my RDLC.
How do I have to reference the image data in the report to make that work?

=First(Fields!sh_lot_num_barcode_image.Value, "DataSet1"))

A simple field reference does not seem to do the trick.

Best Answer

So it turns out my question was already asked before and self-answered. Give Tina your vote!

Together with Kevin's answer it got me on the right trail. I ended up adding a property to my Linq stored procedure results class that invokes the image HTML Handler. I changed the MIME type to BMP and it works like a charm - I can drop the database column now and don't need to jump through hoops to compose the URL for the image service. This property below I can directly assign to the image control.

public byte[] NDCLabel {
    get {
        return 
            BarcodeUtilities.ConvertImageToByteArray(
                BarcodeUtilities.GetBarcodeImage(this.ndc) 
                       ,System.Drawing.Imaging.ImageFormat.Bmp);
        }
    }