none
How to create a SSRS Report with dynamic images

    Question

  • I am new to SSRS and need to create a report that displays an image based on a parameter.  Example:

    If @Account = 1, then display 'Image 1'

    If @Account = 2, then display 'Image 2'

    Can you please tell me the best way to store the image in the db table and then how to display the image in the report?  Based on suggestions I've found I have tried storing the path to the image file in the db table that also includes the @Account field and added the image from the Toolbox in SSRS, but am unable to create the custom code needed to display it correctly.

    I have access to modify the table if needed and am using SQL Server and SSRS 2008.

    Thank you for your help and please let me know if I should provide more information.

    Regards,

    Mellisa

    Tuesday, April 06, 2010 10:19 PM

Answers

  • oops just noticed you are doing 2008 and I looked into 2005, but it shouldnt be too different

    if you select the image in the layout and go to the properties window there should be a value field in the Data section where you can create an expression like so:

    =switch(Parameters!pic.Value = 1, "image1.jpg", Parameters!pic.Value = 2, "image2.jpg")

    Tuesday, April 06, 2010 11:37 PM
  • Hi Melissa,

     

    1) Just check whether this blog post addresses your issue

    http://road-blogs.blogspot.com/2010/04/ssrs-reports-using-database-images.html

    Here, rather than storing the path in the DB, you can store the image itself if you want to use the database.

    2) You can also store the images in your report rather than the database by embedding them in the report. For this, right click on the Images in the report data panel and select add new image. Select the embedded option and then upload the image you want by giving the source. Upload all the images you want, lets say Image1 and Image2

    Now you can use the image toolbar and then modify the value property in the wizard to the expression

    =iif(Parameters!Account.Value=1,"Image1","Image2") 

    Note that the names of the images are in quotes.

     

     


    Cheers, Jason ( http://road-blogs.blogspot.com ) P.S. : Please click the 'Mark as Answer' button if a post solves your problem! :)
    Wednesday, April 07, 2010 4:48 AM
  • Hi,

    Reporting Servcies uses three methods to display the image, External, Embedded and Database. To add image to the report,

    1. In Design view, click Image in the Toolbox.

    2. Click a location on the design surface and drag the mouse to create a box that is the size of the desired image. Alternatively, click the design surface to create an image item of fixed size.

    3. In the General page of the Image Properties dialog box, type a name in the Name text box or accept the default.

    4. (Optional) In the Tooltip text box, type text to display when the user hovers the mouse over the image in a report rendered for HTML.

    5. In Select the image source, click the option that specifies where the source for the image exists.
      External   Choose this option when you specify an image that exists on the report server or on a Web server. For this option, you must type a URL to the image or select a dataset field that contains a URL to the image.
      Embedded   Choose this option when you specify an image that is part of the report definition. To add a new embedded image, see How to: Embed an Image in a Report Definition (Reporting Services).
      Database   Choose this option when you specify a dataset field that is bound to a database field that contains an image. For more information, see How to: Add a Data-Bound Image (Reporting Services).

    6. Click OK.

    7. (Optional) Click Size, Visibility, Action, or Border to set additional properties for the image report item.

     

    To display the image dynamically, please add all images in the same position. Set the expression using IIF function in the visiable property to determine which one would be visiable by parameter selection.

    Thanks.

     


    Yao Jie Tang -Microsoft Online Community
    Sunday, April 11, 2010 5:43 PM

All replies

  • oops just noticed you are doing 2008 and I looked into 2005, but it shouldnt be too different

    if you select the image in the layout and go to the properties window there should be a value field in the Data section where you can create an expression like so:

    =switch(Parameters!pic.Value = 1, "image1.jpg", Parameters!pic.Value = 2, "image2.jpg")

    Tuesday, April 06, 2010 11:37 PM
  • Hi Melissa,

     

    1) Just check whether this blog post addresses your issue

    http://road-blogs.blogspot.com/2010/04/ssrs-reports-using-database-images.html

    Here, rather than storing the path in the DB, you can store the image itself if you want to use the database.

    2) You can also store the images in your report rather than the database by embedding them in the report. For this, right click on the Images in the report data panel and select add new image. Select the embedded option and then upload the image you want by giving the source. Upload all the images you want, lets say Image1 and Image2

    Now you can use the image toolbar and then modify the value property in the wizard to the expression

    =iif(Parameters!Account.Value=1,"Image1","Image2") 

    Note that the names of the images are in quotes.

     

     


    Cheers, Jason ( http://road-blogs.blogspot.com ) P.S. : Please click the 'Mark as Answer' button if a post solves your problem! :)
    Wednesday, April 07, 2010 4:48 AM
  • Hi,

    Reporting Servcies uses three methods to display the image, External, Embedded and Database. To add image to the report,

    1. In Design view, click Image in the Toolbox.

    2. Click a location on the design surface and drag the mouse to create a box that is the size of the desired image. Alternatively, click the design surface to create an image item of fixed size.

    3. In the General page of the Image Properties dialog box, type a name in the Name text box or accept the default.

    4. (Optional) In the Tooltip text box, type text to display when the user hovers the mouse over the image in a report rendered for HTML.

    5. In Select the image source, click the option that specifies where the source for the image exists.
      External   Choose this option when you specify an image that exists on the report server or on a Web server. For this option, you must type a URL to the image or select a dataset field that contains a URL to the image.
      Embedded   Choose this option when you specify an image that is part of the report definition. To add a new embedded image, see How to: Embed an Image in a Report Definition (Reporting Services).
      Database   Choose this option when you specify a dataset field that is bound to a database field that contains an image. For more information, see How to: Add a Data-Bound Image (Reporting Services).

    6. Click OK.

    7. (Optional) Click Size, Visibility, Action, or Border to set additional properties for the image report item.

     

    To display the image dynamically, please add all images in the same position. Set the expression using IIF function in the visiable property to determine which one would be visiable by parameter selection.

    Thanks.

     


    Yao Jie Tang -Microsoft Online Community
    Sunday, April 11, 2010 5:43 PM
  • Here is the link for creating ssrs reports with embedded images also based on conditions

    http://road-blogs.blogspot.com/2010/04/ssrs-reports-using-embedded-images.html


    Cheers,
    Jason
    My Blog
    P.S. : Please click the 'Mark as Answer' button if a post solves your problem! :)
    Sunday, April 18, 2010 3:24 PM