Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am developing a web app that has reports created on VS 2019 and run fine from developer mode, but when I publish the website I get "Database logon failed" Error. Database server is on different server that development and production machine.
The error is throwing in line
cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)


Note that I have the same version of crystal reports installed to developer and production machine and aspnet_client folder is on wwwroot.

Development machine: Windows 10, Visual Studio 2019, Crystal Reports v4.0.30319
Production machine: Windows Server 2012 R2, Crystal Reports v4.0.30319

What could be causing this? Thank you in advance.

This is my code:
C#
public void sendEmail(int id)
    {
        ReportDocument cryRpt = new ReportDocument();
        TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
        TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        Tables CrTables;

        cryRpt.Load(@"C:\temp\rep1.rpt");
        
        crConnectionInfo.ServerName = "server";
        crConnectionInfo.DatabaseName = "db";
        crConnectionInfo.UserID = "username";
        crConnectionInfo.Password = "pass";

        CrTables = cryRpt.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }

        cryRpt.SetParameterValue("@ID", id);

        emailCreator(from, to, subject, body, "Attachment.pdf", cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
    }


What I have tried:

1.I enabled 32-bit Application on Application Pool.
2.I changed Identity to Administrator (Application Pool --> Advance Settings) and back to ApplicationPoolIdentity, since it didn't work.
3.I try connecting from IIS Server to database server using the reports credentials to check if I have access and there is access.
Posted
Updated 26-Nov-20 0:45am
v3

1 solution

It seems the good people at CodeProject are a bit tired of all those Crystal Report problems.
So if no one answers your question you might be interested in an alternative like FastReport, see: open-source-reporting-tools[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900