Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
4.67/5 (2 votes)
See more:
I am doing college project . In that they want bonafide certificate. For that i planned to pass textbox string to report.

I googled for passing parameter in winform. Then i got this step by step process. I implemented that using the following steps:

1: In Visual Studio 2010, open your .rdlc file, and open “Report Data” window (If you can not see this window, go to View menu to open it).
2: Right click the “Parameters” node, and add a new Parameter, ie: named it “content“.
3: In your .rdlc file, add a textbox, named it tbContent, and set its filed express to :
C#
=Parameters!content.Value

4: Go to your Form file which include your reporterview control, and add the following code:
C#
this.reportViewer1.LocalReport.ReportEmbeddedResource = "TestReport.Report1.rdlc"; ReportParameter rp = new  ReportParameter("content", this.textBox1.Text); 
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp }); this.reportViewer1.RefreshReport();

5: then you can pass the parameter from the TextBox on the form to .rdlc file;


I added the Microsoft.Reporting.WinForms; assembly reference and used the following code:

C#
this.reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";

ReportParameter rp = new ReportParameter("content", this.textBox1.Text);
//Following line causes exception:
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
this.reportViewer1.RefreshReport();  


But it throws the following exception,

<quote>Local processing Exception was unhandled at the line:
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });.

Thanks in advance!
Posted
Updated 16-Nov-16 9:51am
v2
Comments
Ed Nutting 9-Jun-11 14:32pm    
Edited for: Readability, code formatting and grammer. <code> tags are for single lines of code, <pre> tags are for blocks of code and 'lang' attribute should be set - in your case 'cs' for CSharp (C#). Ed :)
Sagotharan Jagadeeswaran 9-Jun-11 14:56pm    
thank u@
Sagotharan Jagadeeswaran 9-Jun-11 21:39pm    
No solution :(

I cant fix this bug. But i solve my problem,...

I got The Solution. Oh God, It take one day of my life.

I hope This solution is help, whom face the same problem in RDLC report.

ReportParameter[] parms = new ReportParameter[n];
parms[0] = new ReportParameter("param_name", textbox(n-1).text);
parms[1] = new ReportParameter("param_course", textbox(n).text);
this.reportViewer1.LocalReport.SetParameters(parms);
this.reportViewer1.RefreshReport();

Thank you For Ur support.
 
Share this answer
 
Comments
cgtyoder 11-Sep-19 16:47pm    
I am having this problem now - but I'm not sure what you did differently here than in your question. Are at least 2 parameters required? Do the parameter names have to end in _name and _course? Must you use an array of ReportParameter?
 
Share this answer
 
Comments
Sagotharan Jagadeeswaran 10-Jun-11 1:24am    
No friend. I try this, but The same error occurred again. In that question is also asked by me.
ReportViewer1.ProcessingMode = ProcessingMode.Local;
 
Share this answer
 
I got this error as well. In my case, my solution was a WebApplication. I was upgrading my solution from VS2010 to VS2015. Everything worked good on my Computer but publishing the site, was having ths stack trace.

My solution;
the servers didn't had "Microsoft System CLR Types for SQL Server 2014" nor
"Microsoft ReportViewer 2015 Runtime"

Got those from Microsoft site and everything worked like a charm.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900