本文介绍了rdlc页面未获取存储过程结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

以下是我使用rdlc report获取报告的代码.

我有一个带reportviewer的Web表单,单击按钮后,我向存储过程发送了一个案例号,但是我无法获得存储过程的结果

在报告页面的button_click事件中

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

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

            reportViewer1.LocalReport.SetParameters(rp);


并通过选择reportviewer控件的数据源来绑定数据源.

结果仅显示报告页面的设计.报告中没有可用数据.


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.

推荐答案

// 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);



您可以参考下面的链接以获取更多详细信息.

将数据表绑定到rdlc和reportviewer



you can refer to below link for more details.

bind datatable to rdlc and reportviewer


这篇关于rdlc页面未获取存储过程结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

阿里云证书,YYDS!

05-24 22:15