protected void Page_Load(object sender, EventArgs e)
{
ReportDocument ReportDoc;
// 在此处放置用户代码以初始化页面
ReportDoc = new ReportDocument();
ReportDoc.Load(Server.MapPath("MyCrystalReport.rpt"));
#region 解决登录错误问题
TableLogOnInfo logonInfo = new TableLogOnInfo();//
foreach (CrystalDecisions.CrystalReports.Engine.Table tb in ReportDoc.Database.Tables)
{
logonInfo = tb.LogOnInfo;
logonInfo.ConnectionInfo.ServerName = @".\sqlserver2005";
logonInfo.ConnectionInfo.DatabaseName = "FSZJCM0420";//
logonInfo.ConnectionInfo.UserID = "sa";
logonInfo.ConnectionInfo.Password = "123";//
tb.ApplyLogOnInfo(logonInfo);
}
#endregion
CrystalReportViewer1.ReportSource = ReportDoc; ;
}