3 Replies - 6654 Views - Last Post: 15 August 2012 - 12:07 AM Rate Topic: -----

#1 mirzamujib  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-August 12

Display image on rdlc report viewer

Posted 14 August 2012 - 01:25 AM

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"

please help me, I'm stuck here.

Following is the error:

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

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Display image on rdlc report viewer

#2 torind_2000  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 57
  • View blog
  • Posts: 292
  • Joined: 22-August 11

Re: Display image on rdlc report viewer

Posted 14 August 2012 - 06:10 AM

in line 2, change the "+" to an "&"

Here's why I believe you should do that:

Quote

The + Operator (Visual Basic) has the primary purpose of adding two numbers. However, it can also concatenate numeric operands with string operands. The + operator has a complex set of rules that determine whether to add, concatenate, signal a compiler error, or throw a run-time InvalidCastException exception.

The & Operator (Visual Basic) is defined only for String operands, and it always widens its operands to String, regardless of the setting of Option Strict. The & operator is recommended for string concatenation because it is defined exclusively for strings and reduces your chances of generating an unintended conversion.

Was This Post Helpful? 0
  • +
  • -

#3 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 769
  • Joined: 19-October 11

Re: Display image on rdlc report viewer

Posted 14 August 2012 - 08:09 AM

View Postmirzamujib, on 14 August 2012 - 01:25 AM, said:

paramList1.Add(New ReportParameter("Path", "+ /images/CPC.jpg"))      



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

Following is the error:

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


There you have it, right in your text where I used bold text. You are trying to create new instance of ReportParameter, where your second parameter is String, instead of Double as it should be. Or you should rewrite (overload) your constructor of ReportParameter, so it can do something with String as 2nd parameter also.
Was This Post Helpful? 0
  • +
  • -

#4 mirzamujib  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-August 12

Re: Display image on rdlc report viewer

Posted 15 August 2012 - 12:07 AM

View Posttorind_2000, on 14 August 2012 - 06:10 AM, said:

in line 2, change the "+" to an "&"

Here's why I believe you should do that:

Quote

The + Operator (Visual Basic) has the primary purpose of adding two numbers. However, it can also concatenate numeric operands with string operands. The + operator has a complex set of rules that determine whether to add, concatenate, signal a compiler error, or throw a run-time InvalidCastException exception.

The & Operator (Visual Basic) is defined only for String operands, and it always widens its operands to String, regardless of the setting of Option Strict. The & operator is recommended for string concatenation because it is defined exclusively for strings and reduces your chances of generating an unintended conversion.


I tried to replace + with & but its showing error. "Expression expected"
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1