public void ReportLoad(string SQLString, ReportClass report, string dateFrom, string dateTo, string subSQL) { SqlCommand command = new SqlCommand(SQLString, con); SqlDataAdapter sd = new SqlDataAdapter(command); DataSet s = new DataSet(); sd.Fill(s); report.SetDataSource(s.Tables["Table"]); report.SetDatabaseLogon("sa", "erp", "10.168.71.109", "TCRPAY"); // ONLY FOR SUB REPORT SqlCommand subReportCommand = new SqlCommand(subSQL, con); SqlDataAdapter subReportDataAdapter = new SqlDataAdapter(subReportCommand); DataSet subReportDataSet = new DataSet(); subReportDataAdapter.Fill(subReportDataSet); //Subreport Data //System.NullReferenceException: 'Object reference not set to an instance of an object. //This Line report.Subreports["sub1"].SetDataSource(subReportDataSet.Tables["vw_salaryMonth_test2"]; report.SetDataSource(subReportDataSet.Tables["vw_salaryMonth_test2"]); crvSC.ReuseParameterValuesOnRefresh = false; crvSC.ReportSource = report; crvSC.Refresh(); }
subReportDataSet.Tables["vw_salaryMonth_test2"]
null
var dataTable = subReportDataSet.Tables["vw_salaryMonth_test2"]; if (dataTable != null) { report.SetDataSource(dataTable); } else { throw new Exception("No data returned."); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)