Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends

The following is my code for get report using rdlc report.

I have a web form with reportviewer and the in a button click i sent a casenumber to storeprocedure but i can't get the result of the stored procedure

in button_click event of the report page

C#
string casenumber = textBox1.Text;
            ReportParameter[] rp = new ReportParameter[1];
            rp[0] = new ReportParameter("CaseNumber", casenumber);

            reportViewer1.LocalReport.SetParameters(rp);

and bind the datasource by selecting the datasource of the reportviewer control.

and the result is only show the design of report page. no data available in report.
Posted
Updated 1-Aug-14 9:18am
v2
Comments
Jignesh Khant 2-Aug-14 0:59am    
The code you have written is for setting report parameter & not for setting report datasource.

1 solution

Here is the code to bind the Report Viewer using the Stored Procedure and Data Set

C#
// Get the data table using stored procedure.
SqlCommand cmd = new SqlCommand("GetEmployeeDetailsList", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);

// Initialize the Report Data Source.
// DataSet1 -- Name of the Data Set created
ReportDataSource rds = new ReportDataSource("DataSet1", dt);


// bind datatable to report viewer
ReportViewer1.Reset();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
// Path to your rdlc file.
ReportViewer1.LocalReport.ReportPath = Server.MapPath("/EmpReport.rdlc");
// Name of your rdlc file.
ReportViewer1.LocalReport.ReportEmbeddedResource = "EmpReport.rdlc";
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);


you can refer to below link for more details.

bind datatable to rdlc and reportviewer
 
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