Blog Home  Home Feed your aggregator (RSS 2.0)  
Mayur's Blog - CrystalReports throw an error while programatically assigning parameters' values: Missing parameter values
# Monday, February 13, 2017

Type of "ReportClass" that represents report created using RPT file has several APIs to interact with report parameters. You may use the following collection


available within ReportClass to interact with report parameters. Additionally, there is a straight forward way if you are just looking to assign parameter values only. You may use the following method available within the root of ReportClass

SetParameterValue("parameterName", object value)

The important thing here is to supply a proper type of object as value. It is very easy to run into trouble with above method signature.

e.g. If I have a parameter that is for DateTime type, then I may just supply a DateTime value in the above method. However, that should not work and result into Missing Parameter Values exception. It is because the value supplied here should be in the form of an array.

Therefore, you may supply a value object something like the following

var paramVal = new DateTime[] { myDateValue };
SetParameterValue("parameterName", paramVal);

So, in short, be careful while assigning parameter values programmatically. You may want to make sure that the supplied value is in the form of an array even if you are just passing one value.

If you are running into this trouble then this tip might save you some time!

Thanks, a lot for your visit. Happy coding!

Monday, February 13, 2017 6:24:08 PM UTC  #       | 
Copyright © 2022 Mayur Bharodia. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: