Crystal Report突然开始要求登录凭据

时间:2017-04-06 08:02:46

标签: c# asp.net .net crystal-reports

我已经开发了一个Crystal Report,可以在localhost上正常工作但是当我将它部署到Application Server时,它可以正常工作几天,然后突然开始要求登录凭据。我正在使用Windows Authentication

这是我的代码:

    ReportDocument rptDoc = new ReportDocument();

    protected void Page_Load(object sender, EventArgs e)
    {
        ShowReport();
    }

    protected override void OnUnload(EventArgs e)
    {
        if (rptDoc != null)
        {
            rptDoc.Close();
            rptDoc.Dispose();                
        }

        base.OnUnload(e);
    }

    protected void Page_Unload(object sender, EventArgs e)
    {
        if (rptDoc != null)
        {
            rptDoc.Close();
            rptDoc.Dispose();                
        }
    }

    protected void ShowReport()
    {
        QueryString qs = QueryString.GetFromCurrUrl();
        qs = qs.GetDecryptQryString(qs);

        DataTable dt = DAL.GetDT();

        rptDoc.Load(Server.MapPath("~/Reports/RptFiles/report.rpt"));            

        foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in rptDoc.Database.Tables)
        {
            TableLogOnInfo logOnInfo = new TableLogOnInfo();
            logOnInfo = rptDoc.Database.Tables[crTable.Name].LogOnInfo;

            // Set the connection information for the table in the report.
            logOnInfo.ConnectionInfo.ServerName = "Data Source"; 
            logOnInfo.ConnectionInfo.DatabaseName = "Initial Catalog";
            logOnInfo.ConnectionInfo.UserID = ""; //I am using Windows Authentication that's why UserId and Password are Empty
            logOnInfo.ConnectionInfo.Password = "";
            //logOnInfo.ConnectionInfo.IntegratedSecurity = true; //I have tried this line as well after which report stops working totally. 
            rptDoc.Database.Tables[crTable.Name].ApplyLogOnInfo(logOnInfo);
        }

        rptDoc.Database.Tables[0].SetDataSource(dt);
        crViewer.ReportSource = rptDoc;
        crViewer.DisplayGroupTree = false;
        crViewer.DataBind();
    }

以下是我每2,3天后得到的错误。然后我在Server上执行命令iisreset,它再次开始工作2,3天。

enter image description here

0 个答案:

没有答案