Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I've problem in displaying image on my rdlc (Microsoft Report Viewer) report. I took picture box on my report and made its properties as SOURCE=EXTERNAL, VALUE=Parameters!Path.value where Path is my Report Parameter.

Below is the code to display image on Report load event:

Dim paramList1 As New Generic.List(Of ReportParameter)
paramList1.Add(New ReportParameter("Path", "+ /images/CPC.jpg"))       Me.ReportViewer1.LocalReport.SetParameters(paramList1)


I'm facing problem on the second line of my code i.e. " + /images/CPC.jpg"

Plz help me, I'm stuck here.

Following is the error:

Conversion from string " /images/CPC.jpg" to type 'Double' is not valid.

Thanks
Posted
Updated 15-Jan-21 15:27pm

VB
Dim arrPic as byte() = 'Load the image as array of byte'
'Convert byte() to BASE64
Dim sIMGBASE64 as String = Convert.ToBase64String(arrPic))
'Add the BASE64 stream to the parameters
paramList1.Add(New ReportParameter(<sparamname>, sIMGBASE64)

where
sParamName is a parameter of the Report

On the Report set the "Value" property of Picture Box like this:
VB
Value=System.Convert.FromBase64String(Parameters!<sparamname>.Value)
 
Share this answer
 
v2
make sure you add
"File:///"
in front of the image path
and in the report parameter you created for Path, make sure it is of type string, and not double or integer
 
Share this answer
 
Try this, I use this in External Images for RDLC.
Just initialize the image parameter like a normal string parameter, and set the Me.ReportViewer1.LocalReport.EnableExternalImages to TRUE
Dim ImgParam As New ReportParameter("ImgParam", "")

Dim path = _
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

ImgParam = New ReportParameter("ImgParam", path & "\myImg.png", True)
Dim parameters As ReportParameter() = {ImgParam}

ReportViewer1.Reset()
With Me.ReportViewer1.LocalReport
    .EnableExternalImages = True
    .SetParameters(parameters)
End With

Me.ReportViewer1.RefreshReport()
 
Share this answer
 
v2
your code is in VB.net so use " & " instead of " + " .... may be that is the problem
 
Share this answer
 
Comments
CHill60 12-Jun-13 18:54pm    
The question is nearly a year old ...and the + was inside quotes. Nice that you are trying to help but it would be better to help on more recent questions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900