2

Ok

I'm working on a little project at the moment, the Report expects an int but the ReportParameter class only lets me have a value that's a string or a string[]

How can I pass an int?

thanks

dan

danswain
  • 4,171
  • 5
  • 37
  • 43

3 Answers3

3

You can call the method GetReportParameters() which will return a ReportParameter[] array. If you iterate through each parameter and look at its Type property it will indicate if it is an int. The Type property is an enum of type ParameterTypeEnum and would be ParameterTypeEnum.Integer for an int.

Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
John Lemp
  • 5,029
  • 3
  • 28
  • 36
1

I would try:

var rp = new ReportParameter("IntValue", intValue.ToString());
report.SetParameters(new ReportParameter[]{rp});
Thedric Walker
  • 1,817
  • 15
  • 23
  • But what if the ReportParameter is of type int... as in I don't want to use .ToString() I want to use an int. Thanks – danswain Nov 03 '08 at 10:08
  • Since ReportParameter.Value is a string you would have to define an implicit operator to not be able to use ToString(). – Thedric Walker Nov 07 '08 at 12:02
0

Still no answer to this one, ended up casting in the underlying stored procs.

danswain
  • 4,171
  • 5
  • 37
  • 43
  • 1
    The weird things is that when you declare a report parameter in the report itself (*.rdl) it can have a type like integer, boolean, DateTime, etc, but the ReportParameter constructor only takes strings. This means that DateTime values have to be cast to string which causes problems when the local of the report server is different from that of the client. – Captain Sensible Nov 27 '12 at 07:05