published reports don't work - Database logon

2020-02-16 04:06发布

问题:

I am developing a simple web app that has 3 reports created on VS 2013, for some reason those reports run fine from developer mode, but when I publish the website they give me "Database logon failed" Error. What could be causing this? VS is installed on the same server that I am publishing the reports. I have created a local admin user with exactly the same info as the ODBC connection logon user for IIS authentication, but still no luck.

below is my code:

public partial class OpenWOsWebForm : System.Web.UI.Page
    {
        ConnectionInfo EPAKconnectionInfo = new ConnectionInfo();

        protected void SetConnectionInfo()
        {

            EPAKconnectionInfo.ServerName = ConfigurationManager.AppSettings["EPAK_SERVER_NAME"];
            EPAKconnectionInfo.UserID = ConfigurationManager.AppSettings["EPAK_USER_NAME"];
            EPAKconnectionInfo.Password = ConfigurationManager.AppSettings["EPAK_PASSWORD"];
        }

        private void Page_Init(object sender, EventArgs e)
        {

            ReportDocument report = new ReportDocument();
            report.Load("C:\\Delray Beach\\Delray Beach\\Reports\\OpenWOsReport.rpt");
            SetConnectionInfo();
            TableLogOnInfo crTableLogoninfo = new TableLogOnInfo();

            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in report.Database.Tables)
            {
                crTableLogoninfo = CrTable.LogOnInfo;
                crTableLogoninfo.ConnectionInfo = EPAKconnectionInfo;
                CrTable.ApplyLogOnInfo(crTableLogoninfo);
            }
            foreach (ReportDocument subreport in report.Subreports)
            {
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in subreport.Database.Tables)
                {
                    crTableLogoninfo = CrTable.LogOnInfo;
                    crTableLogoninfo.ConnectionInfo = EPAKconnectionInfo;
                    CrTable.ApplyLogOnInfo(crTableLogoninfo);
                }
            }

            OpenWOsViewer.ReportSource = report;

            OpenWOsViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
        }
    }

Thanks

回答1:

Besides "Database logon failed", does it say "Unable to connect: incorrect log on parameters"?

If so, try this: https://stackoverflow.com/a/24578304/2248943

And try these:

  1. kill the asp.net proccess (w3wp.exe or aspnet.exe) (it will restart) .
  2. if you are using a XSD file, check it's location path in the RPT, try to "set location" again; if it does not work, try to remove the tables and include them ok (this will be hard-working).

I faced this problem many times and each case was solved by one of these actions.



回答2:

In my case the problem was that on IIS Application Pools/ my web app/ Advanced Settings the 32 bit Applications was disable and I wasn't including on my project the folder aspnet_client where crystal run-times files are storage, so the time I was publishing the app, those files wren't transferred. Once I enabled the connection and included that folder the issue got resolved.