在水晶报表的子报告中不取回数据。

时间:2022-08-19 16:39:04

I have some problem on fetching data in sub report. In crystal report data fetch in proper manner but when i click on sub report it show "No valid report source is available"

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

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;

        }

1 个解决方案

#1


0  

This is happening in the viewer, right? If so, the error could be the result of the viewer not being able to find the report in session. Check out the thread "No valid report source is available. in asp.net sap crystal report".

这发生在观众身上,对吧?如果是这样,则错误可能是查看器无法在会话中找到报告的结果。检查线程“没有有效的报告源可用”。在asp.net sap crystal report中。

#1


0  

This is happening in the viewer, right? If so, the error could be the result of the viewer not being able to find the report in session. Check out the thread "No valid report source is available. in asp.net sap crystal report".

这发生在观众身上,对吧?如果是这样,则错误可能是查看器无法在会话中找到报告的结果。检查线程“没有有效的报告源可用”。在asp.net sap crystal report中。