How to dynamically display the Images in SQL Server 2005 Reporting Services Reports

Customers like to have have personalization in the aplications they use. In ASP.Net we have master pages, themes etc. that does the job for us but the question for personalizing the reports still holds back. Most companies will like to add their logo on the top of the reports.

Generally the reports look similar in structure like a Profit Loss Statement, Balance Sheet, BOM etc. When the structure of the report body remains the same, it is an issue displaying different images on the top of the report.

To overcome this issue we can use ADO.Net to do the wonders with SQL Server 2005 Reporting Services Reports. In the SSRS reports we can use the image user control and bind that to a data source. We can name the data source like “dsImage” that contains a single field to contain the image. The image user control will be bound to the field in the “dsImage” data source. The user control could be put on the top of the report where we want to display the logo image.

When the user requests the report:

We can read the image stored in the local folder by using a .Net FileStream get the byte array and then create a .Net DataTable. Within the data table we create a column with the same name as the field name given in the “dsImage” data source in the SSRS. Add this byte array as the data in the first row of the column.

Now we add this DataTable as the report data source using Microsoft.Reporting.<WinForms/WebForms>.ReportDataSource. We will provide the first parameter as “dsImage” and second parameter as the DataTable. Now we add this data source to the report using the report viewer.

After this we can refresh the report and display the report.

Comments (0)

Skip to main content