0

我有一个如下所示的代码:

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()); 

程序抛出异常而不进入函数内部

抛出的异常是“对象引用未设置为对象实例”。

该函数需要三个参数

public DataSet SetDataInDataSetFromEnumerableList(ref DataSet DS, object obj, params string[] FieldNames)
        {
             return ds;
        }
4

2 回答 2

0

你需要检查reportData。这将是 null 这就是它抛出异常的原因。或者它可能是 SetDataInDataSetFromEnumerableList 方法。调试到这个方法,看看究竟什么是空的。

于 2013-10-09T06:24:25.643 回答
0

使用异常的堆栈跟踪,Luc

于 2013-10-09T07:18:58.353 回答