Display the images in the rdlc reports, where the images are retrived from the database.
Most of us using rdlc reports to show the reports and sometimes we need to show up the images in the reports. Let's see the method to work out this, step by step.
Display the images (saved in the databse) in the report viewer
Using the code
We usually save the images of the Database and then retrieve it to use for our purpose.Let us fallow the same in the scenario, I have already explained how to upload the images to the Database in the below link
We would save the image as image data type in the Data base, it is stored as an binary format, the following code snippet is used to fill the data table with data retrieved from the Database.
String connStr= "Data Source=Server;Initial catalog=Database;User
using (SqlConnection conn = new
string sql = "SELECT * FROM EmpTable ORDER BY
using (SqlCommand cmd = new SqlCommand(sql,
using (SqlDataAdapter ad = new
Now we should create an strong typed dataset, with the same column name and datatypes as per in the database
Now (i) create an report viewer (ii) add datatable as the datasource and (iii) drop a Table from the toolbox
Add the columns as fallow
In the data column of Empphoto just right click and select image properties
(i) select the image source as "Database"
(ii) select the column as "EmpPhoto"
(iii) select the MIME type as per the image you uploaded.
Following code snippet is meant for achieving the loadingof report in the report viewer.
string exeFolder = new DirectoryInfo(Application.StartupPath).Parent.Parent.FullName;
string reportPath =
this.report.LocalReport.ReportPath = reportPath;
Now compile and run application, our task is achieved.
The images (which are saved in the database) can be displayed in edlc reports with simple method as described above.