I have a code as shown below:
try
{
strReportName = Application.StartupPath + "\\Report\\Accounts\\AccTrialBalanceCrystalReport.rpt";
DataSet ds = new System.Data.DataSet();
SchoolSoulLibrary.clsCommonVariables OClsCommonVariables = new SchoolSoulLibrary.clsCommonVariables();
ds = OclsCommonVariables.SetDataInDataSetFromEnumerableList(ref ds, reportData.AsEnumerable()); // Throws exception at this line.
string[,] AryParameter = new string[,]
{
{"totalOpeningDr", vOpDr.ToString()},
{"totalOpeningCr", vOpCr.ToString()},
{"totalCurrentDr", vCurDr.ToString()},
{"totalCurrentCr", vClsngDr.ToString()},
{"totalClosingDr", vCurCr.ToString()},
{"totalClosingCr", vClsngCr.ToString()},
{"schoolName", clsSchoolSoulObjects.OAcdSchoolInfo.SchoolName},
{"@pStartDate", startDate.ToString()},
{"@pEndDate", endDate.ToString()},
{"@pSchoolId", schId.ToString()},
};
SchoolSoulLibrary.clsCrystalReport.SetReportSourceUsingReportPath(strReportName, ds, ref crystalReportViewer1, AryParameter);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
At this line
ds = OclsCommonVariables.SetDataInDataSetFromEnumerableList(ref ds, reportData.AsEnumerable());
the program throws exception without goin inside the function
Exception thrown is "Object reference not set to an instance of object".
The function takes three arguements
public DataSet SetDataInDataSetFromEnumerableList(ref DataSet DS, object obj, params string[] FieldNames)
{
return ds;
}