locked
Invalid report file path RRS feed

  • Question

  • User2028249543 posted

    Hi.

    I am trying to export my crystal report to PDF however it gives me an error "Invalid report file path".

    Here's the snippet:

     protected void btntest_Click(object sender, EventArgs e)
            {
                ReportDocument rptDocmnt = new ReportDocument();
                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
                ConnectionInfo crConnectionInfo = new ConnectionInfo();
                Tables CrTables;

                try
                {
                    crConnectionInfo.ServerName = "192.168.0.246";
                    crConnectionInfo.DatabaseName = "DB_CRITH";
                    crConnectionInfo.UserID = "sa";
                    crConnectionInfo.Password = "123456";
                    CrTables = rptDocmnt.Database.Tables;
                    foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                    {
                        crtableLogoninfo = CrTable.LogOnInfo;
                        crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                        CrTable.ApplyLogOnInfo(crtableLogoninfo);
                    }

                    string strRptLoad = Server.MapPath("../Reports/PayDetails.rpt");
                    rptDocmnt.Load(strRptLoad);
                    
                    BinaryReader stream = new BinaryReader(rptDocmnt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-disposition", "attachment;filename=payment.pdf");
                    Response.AddHeader("content-length", stream.BaseStream.Length.ToString());
                    Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
                    Response.Flush();
                    Response.Close();
                    //crvPay.ReportSource = rptDoc;
                }
                catch (Exception ex)
                {
                    MsBx(ex.Message);
                }
            }

    The report path is located at "../Reports/PayDetails.rpt" however could not figure it out what went wrong. Please help. Thanks.

    Saturday, March 3, 2012 2:39 AM

Answers

  • User-434868552 posted

    @ sheen_buhay

    sheen, it might help you to help yourself and also your peers here at forums.asp.net to help you if you would walk your code line by line in the debugger* and show us the relevant values that are related to your code snippet ... also, please show us the full stack trace.

    g.

    * walking your code with your debugger:

       video, c. 8 minutes:  http://msdn.microsoft.com/en-ca/vstudio/ee672313.aspx
         "How Do I: Step with The Debugger in Visual Studio?"

       Debugging:  http://lmgtfy.com/?q=debug+visual+studio+2010

       example:  http://www.codeproject.com/KB/cs/MasteringInDebugging.aspx

       videos:   http://www.youtube.com/watch?v=z5gBIizwsY0

       search videos at Google with               debug visual studio 2010

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 3, 2012 5:39 AM
  • User-121157572 posted

    Hi,

    It is sure that your path is not correct so let's try with different option.

    string strRptLoad = Server.MapPath("~/Reports/PayDetails.rpt");


    In above code I assume that report folder directly inside your root folder. If you have some more folder then add that also just before the reports folder.
    let me know if doesn't works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 3, 2012 8:18 AM

All replies

  • User-926023460 posted

    write like

    string strRptLoad = Server.MapPath("..\\Reports\\PayDetails.rpt");

    now it can be work..

    try this.

    Saturday, March 3, 2012 3:06 AM
  • User2028249543 posted

    @Mahesh,

    I appreciate your time looking into my concern, I've tried your idea however it's not working as well.

    Please help. Thanks.

    Saturday, March 3, 2012 3:17 AM
  • User-434868552 posted

    @ sheen_buhay

    sheen, it might help you to help yourself and also your peers here at forums.asp.net to help you if you would walk your code line by line in the debugger* and show us the relevant values that are related to your code snippet ... also, please show us the full stack trace.

    g.

    * walking your code with your debugger:

       video, c. 8 minutes:  http://msdn.microsoft.com/en-ca/vstudio/ee672313.aspx
         "How Do I: Step with The Debugger in Visual Studio?"

       Debugging:  http://lmgtfy.com/?q=debug+visual+studio+2010

       example:  http://www.codeproject.com/KB/cs/MasteringInDebugging.aspx

       videos:   http://www.youtube.com/watch?v=z5gBIizwsY0

       search videos at Google with               debug visual studio 2010

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 3, 2012 5:39 AM
  • User-121157572 posted

    Hi,

    It is sure that your path is not correct so let's try with different option.

    string strRptLoad = Server.MapPath("~/Reports/PayDetails.rpt");


    In above code I assume that report folder directly inside your root folder. If you have some more folder then add that also just before the reports folder.
    let me know if doesn't works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 3, 2012 8:18 AM