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;
}
什麼行會拋出錯誤? – JoeFletch
未顯示任何錯誤...它不提取數據... –