How to pass an Image as a parameter to an SSRS Report

vsslasd 556 Reputation points
2023-01-31T20:50:06.0033333+00:00

Hello,

We need to pass an image as a parameter to an SQL SSRS Report.
How would this be done since there is only a date, number, bit and text type for SSRS parameter types ?

Thank you

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,790 questions
{count} votes

5 answers

Sort by: Most helpful
  1. AniyaTang-MSFT 12,306 Reputation points Microsoft Vendor
    2023-02-01T01:52:46.52+00:00

    Hi @vsslasd

    First, when setting parameters, you can set the path of the image as the value of the parameter. Then when inserting a picture, set the path in the picture property to this parameter.

    For more details, you can refer to this link: Image parameter on ssrs report.

    Best regards,

    Aniya

    0 comments No comments

  2. Olaf Helper 40,656 Reputation points
    2023-02-01T07:02:56.3233333+00:00

    Pass an image in which way? As file name/URL it's possible.

    But not as BLOB or object.

    0 comments No comments

  3. vsslasd 556 Reputation points
    2023-02-02T22:08:38.33+00:00

    Hello and thank you both.

    Neither of those will work. The image itself must be passed.

    I believe the image can be converted to varchar(max) Base64, passed to a stored procedure and then the following command to convert from varchar(max) Base64 to a varbinary:
    SET @CapturedPhoto = CAST('' AS XML).value('xs:base64Binary(sql:variable("@SignImage"))', 'VARBINARY(MAX)');

    0 comments No comments

  4. vsslasd 556 Reputation points
    2023-02-02T22:11:02.08+00:00

    SET @CapturedPhoto = CAST('' AS XML).value('xs:base64Binary(sql:variable("@SignImage"))', 'VARBINARY(MAX)');

    0 comments No comments

  5. AniyaTang-MSFT 12,306 Reputation points Microsoft Vendor
    2023-02-03T07:03:15.61+00:00

    Hi @vsslasd

    Yes, if you want to store the image itself in the database, you can write the picture as binary data directly into a database field. It can be written using background programs or T-SQL commands.

    Shown here is the method using the T-SQL command, executing the SQL OPENROWSET command with the BULK and SINGLE_BLOB options. For more details you can check this link: Save Image to Database Table in SQL Server.

    3

    4

    I am not very familiar with programming, if you need help in this area, you can go to the relevant tag to ask more professional personnel.

    Once images are stored in the database, paginated reports can reference such images, known as "data-bound images". To add data bound image to paginated report, you can refer to this link: Add a data-bound image to a paginated report.

    Then we can experiment with parameters. Here I have made a table with the picture name as a parameter.

    5

    Best regards,

    Aniya

    0 comments No comments