Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to display report but an error occurred in this line

rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "ExportedReport.pdf");
ERROR

An exception of type 'CrystalDecisions.CrystalReports.Engine.LoadSaveReportException' occurred in CrystalDecisions.CrystalReports.Engine.dll but was not handled in user code

Additional information: Invalid report file path.

What I have tried:

Code:

ASP.NET
private void ViewReport()
        {
        rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "ExportedReport.pdf");

          Response, false, "ExportedReport.pdf");

            if (rpt != null)
            {
                rpt.Dispose();
                rpt.Close();
            }
        }



rpt = new ReportDocument();
string sRptPath = "ERPSolution-NL/Admin_Reports/CR/";
string sRptTitlePrefix = "";
Posted
Updated 17-May-16 13:12pm
v2
Comments
Herman<T>.Instance 2-May-16 4:56am    
Does the application has sufficient right to write a file in that location?

1 solution

Check your path, when dealing with ASP & Crystal Reports you need to be aware of where the Report is stored relative to where you are running it from.
The best method of doing this is to use a full path from the root of your website instead of a relative path from wherever you are running the report from.
Assuming you have the following structure;
www.myweb.com
www.myweb.com/viewReport.aspx
www.myweb.com/ERPSolution-NL/Admin_Reports/CR/myReport.rpt
To execute the report & view (or download) it from viewReport.aspx you should use the following.
C#
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("~/ERPSolution-NL/Admin_Reports/CR/myReport.rpt"));


Kind Regards
 
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