解决水晶报表登录错误问题

private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   ReportDoc  = new  ReportDocument();
   ReportDoc.Load(Server.MapPath("myReport.rpt"));


      #region 解决登录错误问题
   TableLogOnInfo  logonInfo  = new TableLogOnInfo();//
   foreach( CrystalDecisions.CrystalReports.Engine.Table tb in ReportDoc.Database.Tables)
   {
    logonInfo = tb.LogOnInfo;
    logonInfo.ConnectionInfo.ServerName = "(local)";
    logonInfo.ConnectionInfo.DatabaseName = "myDatabase";
    logonInfo.ConnectionInfo.UserID = "sa";
    logonInfo.ConnectionInfo.Password = "";
    tb.ApplyLogOnInfo(logonInfo);
   
   }
   #endregion


   CrystalReportViewer1.ReportSource = ReportDoc;

  } 

你可能感兴趣的:(解决水晶报表登录错误问题)