0
votes
ReportDocument crystalReport = new ReportDocument();
            crystalReport.Load(Server.MapPath(Report));
            crystalReport.SetDatabaseLogon("glfuser", "glfuserpass", "glfcol", "");
            crvReport.RefreshReport();
            crvReport.ReportSource = DAC.GenerateReport(Report, Query);
            crvReport.ID = ReportName;
        crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\ASD.pdf");

Trying to export my report in PDFformat in my local PC after I get report in report viewer. I am getting report but when I am trying to export it with ExportToDisk method I get error

Database logon failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Database logon failed.

Source Error:

Line 19: //crvReport.ReportSource = DAC.GenerateReport(Report, Query); Line 20: //crvReport.ID = ReportName; Line 21: crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\ASD.pdf");

1
At a guess - I'd say your database login credentials were wrong, or the database does not exist. - PhillipH
but when I remove the last line (crystalReport.ExportToDisk..) I am getting my report. - Sajeesh Aravind

1 Answers

2
votes

I think you need to declare your database at following line

crystalReport.SetDatabaseLogon("glfuser", "glfuserpass", "glfcol", "dbname");