0

这段代码有什么问题:

ReportDocument cryrpt = new ReportDocument();
            TableLogOnInfos crtablelogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
            ConnectionInfo crconnectioninfo = new ConnectionInfo();
            Tables CrTables;

            cryrpt.Load("C:\\Documents and Settings\\Administrator\\Desktop\\minfatora11-7--\\minfatora\\minfatora\\Treasury_account_out_come.rpt");

            crconnectioninfo.ServerName = "localhost";
            crconnectioninfo.DatabaseName = "MNFATOR";
            crconnectioninfo.UserID = "ICMADMIN";
            crconnectioninfo.Password = "ICMADMIN";

            CrTables = cryrpt.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }





            cryrpt.RecordSelectionFormula = "select * from tblxxx where xxx=2";
            cryrpt.Refresh();
            allReportViewer.ReportSource = cryrpt;

我收到错误:“对象引用未设置为对象的实例。” 在线上:

CrTable.ApplyLogOnInfo(crtableLogoninfo);
4

2 回答 2

0

CrTablesnull,当你把你的桌子放在这一行时

CrTables = cryrpt.Database.Tables;
  1. 您可以验证加载路径
  2. 或检查您的文件 Treasury_account_out_come.rpt 的语法
于 2012-08-18T12:01:31.377 回答
-1
cryrpt.RecordSelectionFormula = "{tblxxx.xxx}=2";
于 2020-07-02T22:12:29.340 回答