• 0
  • 215
  • 0

Crystal Reports - Database Login failed only on production machine

Nov 26 2020 4:08 AM


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


Note that I have the same version of crystal reports installed to developer and production machine and aspnet_client folder is on wwwroot and 32-bit Application is enabled on Application Pool.
I also changed Identity to Administrator (Application Pool --> Advance Settings) and back to ApplicationPoolIdentity, since it didn't work.
I try connecting from IIS Server to database server using the reports credentials to check if I have access and there is access.

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:

  1. public void sendEmail(int id)  
  2. {  
  3. ReportDocument cryRpt = new ReportDocument();  
  4. TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();  
  5. TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();  
  6. ConnectionInfo crConnectionInfo = new ConnectionInfo();  
  7. Tables CrTables;  
  8. cryRpt.Load(@"C:\temp\rep1.rpt");  
  9. crConnectionInfo.ServerName = "server";  
  10. crConnectionInfo.DatabaseName = "db";  
  11. crConnectionInfo.UserID = "username";  
  12. crConnectionInfo.Password = "pass";  
  13. CrTables = cryRpt.Database.Tables;  
  14. foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)  
  15. {  
  16. crtableLogoninfo = CrTable.LogOnInfo;  
  17. crtableLogoninfo.ConnectionInfo = crConnectionInfo;  
  18. CrTable.ApplyLogOnInfo(crtableLogoninfo);  
  19. }  
  20. cryRpt.SetParameterValue("@ID", id);  
  21. emailCreator(from, to, subject, body, "Attachment.pdf", cryRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));  
  22. }  

Answers (4)