我正在使用存储过程生成报告;但是当我执行时,我看到enter image description here
1:https://i.stack.imgur.com/pvnKg.png,但是当我执行存储过程时,实际上会显示数据。
后面的代码
string strSQLconstring = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ToString();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
//report path
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
SqlDataAdapter adp = new SqlDataAdapter("PP_CountReturn", strSQLconstring);
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
//object of Dataset DataSet
DataSet ds = new DataSet();
adp.Fill(ds, "PP_CountReturn");
//Datasource for report
ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]);
ReportViewer1.Width = 600;
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
答案 0 :(得分:0)
这是我加载ReportDataSource
的方式:
ReportDataSource reportDataSource = new ReportDataSource();
//...
// Query the database...
//...
reportDataSource.Name = "DataSet1";
reportDataSource.Value = ds.Tables[0];
this.ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
this.ReportViewer1.RefreshReport();