TableLogOnInfo logOnInfo = new TableLogOnInfo();
//这里必须声明一个Reportdocument对象 Report, 同时加载数据报表
ReportDocument oRpt = new ReportDocument();
oRpt.Load(Server.MapPath("CrystalReport.rpt"));
//建立安全信息
logOnInfo.ConnectionInfo.ServerName = "FS02";
logOnInfo.ConnectionInfo.DatabaseName = "ACData";
logOnInfo.ConnectionInfo.UserID = "hins";
logOnInfo.ConnectionInfo.Password = "12345";
oRpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
//建立 .rpt 文件与 CryStalReportViewer 文件之间的连接
CrystalReportViewer1.ReportSource = oRpt;