You are on page 1of 3

Display Image From Database in .rdlc report - Stack Overflow http://stackoverflow.

com/questions/10013322/display-image-from-database-in-rdlc-report

sign up log in tour help

_
Stack Overflow is a community of 4.7 Join the Stack Overflow community to:
million programmers, just like you,
helping each other.

Join them; it only takes a minute:


Ask Answer and help Get recognized for your
Sign up programming your peers expertise
questions

Display Image From Database in .rdlc report

I have one simple report in which I display company information.

In my sql database I have a CompanyMaster table in which i have one column Company Logo. In that column I only store the path of the
company logo image.

Now i want to display company logo in report with company information,

How do I do this?

rdlc

edited Apr 4 '12 at 14:49 asked Apr 4 '12 at 14:34


hawbsl Sagar Savsani
4,367 11 44 87 15 3 9

3 Answers

You could use Image control in rdlc file. Common approach is to write an Webservice that
returns the Image content. So your Image URL will point to web service URL.

You webserivce class needs to inherit ImageHandler as follows:

<%@ WebHandler Language="C#" Class="ServeImage" %>

using System;
using System.Web;
using System.Drawing.Imaging;
using Microsoft.Web;
using MyControllers;

1 of 3 24/02/2016 3:58 PM
Display Image From Database in .rdlc report - Stack Overflow http://stackoverflow.com/questions/10013322/display-image-from-database-in-rdlc-report

public class ServeImage : ImageHandler {

public ServeImage()
{
}

public override ImageInfo


GenerateImage(System.Collections.Specialized.NameValueCollection parameters)
{
ImageInfo retVal = null;

if (parameters["ID"] != null)
{
MyController myCntl = new MyController();
// myCntl.GetImageFromDB returns the binary[] content from database
retVal = new ImageInfo(myCntl.GetImageFromDB(parameters["ID"]));
}

return retVal;
}
}

answered May 18 '12 at 4:25


Yogesh P
21 4

Ok.. I think, I should be sorry for making you click on to an another page. Time for steps.

1.) EnableExternaImages= true for your sample report.

2.) Insert an image in your Report. Set the image source as external.

3.) Enter the expression in "use this image".

4.) Enter the value of your image file link that is saved in Database eg . of such expression is :
"file:/// " + First(Fields!Imagelink.Value, "DataSet1") + ".jpeg"

5.) Important thing is that your Imagelink value must be the complete path to that image.

Note use "file:///" before the link.


6.) Any more issue please comeback and ask again. :-)

edited May 22 '14 at 12:14 answered Jul 12 '13 at 8:40


Rahul
232 5 27

I hope this may help miss Kleopatra – Rahul Jul 12 '13 at 10:54

2 of 3 24/02/2016 3:58 PM
Display Image From Database in .rdlc report - Stack Overflow http://stackoverflow.com/questions/10013322/display-image-from-database-in-rdlc-report

1- Create Text Parameter

2- Add Image Control to the Report

3- Set the Image to be External external and set "Use this image" to be the parameter:
[@ParameterName].

4- Finally Set the Parameter Value in Code behind before loading the report.

Setting image source in RDLC report dynamically

answered Feb 25 '13 at 13:38


Muhammad Omar
ElShourbagy
1,987 11 23

3 of 3 24/02/2016 3:58 PM

You might also like