0

我在子报告中获取数据时遇到了一些问题。在水晶报表中以正确的方式获取数据,但是当我单击子报表时,它显示“没有可用的有效报表源”

protected void btnSearch_Click(object sender, EventArgs e)
        {
            ReportDocument rptDoc = new ReportDocument();
            ComplaintTrackingSystem.Reports.Datas dss = new Reports.Datas();
            DataTable dt = new DataTable();
            // Just set the name of data table
            DataSet ds;
            Hashtable ObjParameters = new Hashtable();
            BusinessLogicLayer ObjBusiness = new BusinessLogicLayer();
            ObjParameters.Add("@From", dateFrom.SelectedDate.ToShortDateString());
            ObjParameters.Add("@To", dateTo.SelectedDate.ToShortDateString());
            ds = ObjBusiness.SPDataSet(ObjParameters, "ReportForAverageCompt");
            dt.TableName = "Crystal Report Example";
            dt = ds.Tables[0]; //This function is located below this function
            dss.Tables[0].Merge(dt);
            // Your .rpt file path will be below
            rptDoc.Load(HttpContext.Current.Server.MapPath("../Reports/AverageReport.rpt"));
            //set dataset to the report viewer.
            rptDoc.SetDataSource(dss);
            CrystalReportViewer1.ReportSource = rptDoc;
            Session["Report"] = rptDoc;
            ComplaintTrackingSystem.Reports.Datas dssNew = new Reports.Datas();
            ds.Clear();
            ds = ObjBusiness.SPDataSet(ObjParameters, "ReportForResolvedCompt");
            dt.TableName = "Crystal Report";
            dt = ds.Tables[0]; //This function is located below this function
            dssNew.Tables[0].Merge(dt);
            //set dataset to the report viewer.
            rptDoc.Subreports["AdminReport.rpt"].SetDataSource(dssNew);
            rptDoc.Refresh();
            CrystalReportViewer1.ReportSource = rptDoc;

        }
4

1 回答 1

0

这发生在查看器中,对吗?如果是这样,错误可能是查看器无法在会话中找到报告的结果。查看线程“没有可用的有效报告源。在 asp.net sap 水晶报告中”。

于 2013-08-09T17:25:15.870 回答