此代码有什么问题:
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);
答案 0 :(得分:0)
当您在此行中获得表格时,CrTables
为null
CrTables = cryrpt.Database.Tables;
答案 1 :(得分:-1)
cryrpt.RecordSelectionFormula = "{tblxxx.xxx}=2";