我有一个代码如下所示:
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);
}
在这一行
ds = OclsCommonVariables.SetDataInDataSetFromEnumerableList(ref ds, reportData.AsEnumerable());
程序在函数
中抛出异常而没有goin抛出的异常是“对象引用未设置为对象的实例”。
该功能需要三个论点
public DataSet SetDataInDataSetFromEnumerableList(ref DataSet DS, object obj, params string[] FieldNames)
{
return ds;
}
答案 0 :(得分:0)
您需要检查reportData。它将为null,这就是它抛出异常的原因。或者它可以是SetDataInDataSetFromEnumerableList方法。调试此方法,看看究竟是什么。
答案 1 :(得分:0)
使用异常的堆栈跟踪Luc