locked
Relative path for an image on the report viewer RRS feed

  • Question

  • I know this has been asked before, and some say it's possible others say not possible.

    I have customer form where the user can find any image on their PC of their client and it stores the path to the image and loads it back to the form when it loads.

    I have a report. I have tried external and set the local to external true. I need to know what code to use to get the relative path for the report viewer so that it will load the pictures back to the report.

    I have seen no examples of this but have seen a screenshot on gotreportviewer so I know it has to be possible...

    Does anyone have any samples of code or can anyone explain how to get the relative path back to the image from the report so that it will show up in the report. This should be easy but its not.

    I was able to do this in vb6 but can't get this to work in vb net.

    Wednesday, May 19, 2010 4:30 PM

Answers

  • Ok, going to answer my own question. This works for me, but it might not work for you , or you might have a better way to do this.

     

     

    ="file:///" & Fields!BeforePhoto.Value
    Set the source to External
    when you do this you do not need to put in the mimet type. it's ignored anyway.
    MOST important...

    For the reportviewer..refresh the report BEFORE external is set to true. Otherwise you get the red x.
    dataset adapter fill here
    Me.ReportViewer1.RefreshReport()
    ReportViewer1.LocalReport.EnableExternalImages = True
    Me.ReportViewer1.RefreshReport()

     

    This works....must refresh BEFORE external is set to true.....

    • Marked as answer by mindserve Thursday, June 10, 2010 2:31 PM
    Monday, May 24, 2010 10:07 PM

All replies

  • Ok, going to answer my own question. This works for me, but it might not work for you , or you might have a better way to do this.

     

     

    ="file:///" & Fields!BeforePhoto.Value
    Set the source to External
    when you do this you do not need to put in the mimet type. it's ignored anyway.
    MOST important...

    For the reportviewer..refresh the report BEFORE external is set to true. Otherwise you get the red x.
    dataset adapter fill here
    Me.ReportViewer1.RefreshReport()
    ReportViewer1.LocalReport.EnableExternalImages = True
    Me.ReportViewer1.RefreshReport()

     

    This works....must refresh BEFORE external is set to true.....

    • Marked as answer by mindserve Thursday, June 10, 2010 2:31 PM
    Monday, May 24, 2010 10:07 PM
  • Check this article: http://www.codeproject.com/KB/reporting-services/MicrosoftReportsII.aspx

     Hope this help!


    Jorge Paulino
    Visual Basic em Português
    http://vbtuga.blogspot.com/

    Tuesday, May 25, 2010 12:50 PM
  • Thanks, I tried that code but got the dreaded RedX.. until the refresh was done before external set to true it just did not load the image for me.  I don't know why but it wouldn't load.

    Not sure about the 3 forward slashes but it works so for now I will keep that.

     

    Tuesday, May 25, 2010 1:23 PM
  • Hello,

    I got this error either, im trying to set an relative path to my images in report but didn't work with 2 or 3 slashes.

    I already set external images to true before refresh my report.

     I don't know what else to do.
    Saturday, August 18, 2012 11:30 PM