这段代码有什么问题:
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);