Muhammad Gulfam
Muhammad Gulfam

Reputation: 255

Parameters not being passed correctly through code

My report gets data from a stored procedure. Two of the six parameters are dates (toDate and fromDate.) I integrate the report with C# Winforms and I pass the parameters through code the code with:

reportDocument.setParamterValue(0,paramValue);

The report works fine but does not render data despite showing the column header properly. When I refresh the report, it pops up the parameter window again. When I enter the parameters through that window the data shows, including column headers. But it doesn't work when I pass parameters through code.

How can I resolve this?

Upvotes: 1

Views: 122

Answers (3)

Muhammad Gulfam
Muhammad Gulfam

Reputation: 255

I found the error. First it was not working with setting parameters through indexing. so i set the parameters through name as reds suggested. second i was missing the parameters binding with report viewer object. so i added the following line and it worked

crystalReportViewer.ParameterField.addRange(reportDocument.ParameterFields);

Thanks for the answers guys.

Upvotes: 0

Vijunav Vastivch
Vijunav Vastivch

Reputation: 4191

It looks like this:

CRPT.SetParameterValue("smonth", Servercls.month);

See this link for more info.

Upvotes: 1

Alireza Yaghoubi
Alireza Yaghoubi

Reputation: 1

I suggest first of all call procedure in c# environment and save result in datatable and then send datatable to crystal report.

Upvotes: 0

Related Questions