views:

2079

answers:

3

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

+2  A: 

You can call the method GetReportParameters() which will return a ReportParameter[] array. If you iterate through each parameter and look at it's 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.

duckworth
+1  A: 

I would try:

var rp = new ReportParameter("IntValue", intValue.ToString());
report.SetParameters(new ReportParameter[]{rp});
Thedric Walker
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
Since ReportParameter.Value is a string you would have to define an implicit operator to not be able to use ToString().
Thedric Walker
A: 

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

danswain