Search code examples
c#asp.netcrystal-reportscrystal-reports-2008

How To SetDataSouce on Crystal Report WIth Multiple Procedures


enter image description here

Now I am Trying to set the Report Data Source from C# Code on the Asp Page. Using DataSet that had Tables as for Both Procedure added in the report.

the code is as follows

                strPath = HttpContext.Current.Server.MapPath("~/Reports/") + RptName + ".rpt";
                rptDoc.Load(strPath);
                DataSet DS = new DataSet();
                DS = objCommon.FillDataSetMTG(SqlConn, "USP_Report_ExecProcs", Convert.ToInt32(ViewState["Id"]), "JobEntryId");
                rptDoc.SetDataSource(DS);

But report isnt taking the data. any suggestions ?


Solution

  • You can set different datasource for each Tables within the Report, try this one, you must call both "USP_Report_JobCardDet" and "USP_Report_JobCard" stored procedure

                strPath = HttpContext.Current.Server.MapPath("~/Reports/") + RptName + ".rpt";
                rptDoc.Load(strPath);
    
                DataSet DS1 = new DataSet();
                DS1 = objCommon.FillDataSetMTG(SqlConn, "USP_Report_JobCardDet", Convert.ToInt32(ViewState["Id"]), "JobEntryId");
                rptDoc.Tables["USP_Report_JobCardDet"].SetDataSource(DS1);
    
                DataSet DS2 = new DataSet();
                DS2 = objCommon.FillDataSetMTG(SqlConn, "USP_Report_JobCard", Convert.ToInt32(ViewState["Id"]), "JobEntryId");
                rptDoc.Tables["USP_Report_JobCard"].SetDataSource(DS2);