locked
Error "load report failed" while developing a simple crystal report website RRS feed

  • Question

  • User2059853125 posted

    Hi All,

    I am new to asp.net, basically from java background.

    When I am trying to make a simple website which displays a crystal report. Its giving me following error:

    CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the file specified. at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() --- End of inner exception stack trace --- at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) at _Default.Page_Load(Object sender, EventArgs e) 

    Code is as follows:

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    try
    {
    ReportDocument rptDoc = new ReportDocument();
    DataSet1 ds = new DataSet1();
    //dsSample ds = new dsSample(); // .xsd file name
    DataTable dt = new DataTable();

    // Just set the name of data table
    dt.TableName = "Crystal Report Example";
    dt = getAllOrders(); //This function is located below this function
    ds.Tables[0].Merge(dt);

    // Your .rpt file path will be below
    rptDoc.Load(Server.MapPath("SampleReport.rpt"));

    //set dataset to the report viewer.
    rptDoc.SetDataSource(ds);
    CrystalReportViewer1.ReportSource = rptDoc;
    }
    catch (Exception ex)
    {
    Response.Write(ex.ToString());
    }
    }

    public DataTable getAllOrders()
    {
    //Connection string replace 'databaseservername' with your db server name
    string sqlCon = "User ID=sa;PWD=sa ; server=172.16.16.2;INITIAL CATALOG=Test;" +
    "Connect Timeout=0";
    SqlConnection Con = new SqlConnection(sqlCon);
    SqlCommand cmd = new SqlCommand("Select * from emp1");
    DataSet ds = null;
    SqlDataAdapter adapter;
    try
    {
    Con.Open();
    //Stored procedure calling. It is already in sample db.
    //cmd.CommandText = "getAllOrders";
    // cmd.CommandType = CommandType.StoredProcedure;
    cmd.Connection = Con;
    ds = new DataSet();
    adapter = new SqlDataAdapter(cmd);

    adapter.Fill(ds);
    }
    catch (Exception ex)
    {
    throw new Exception(ex.Message);
    }
    finally
    {
    cmd.Dispose();
    if (Con.State != ConnectionState.Closed)
    Con.Close();
    }
    return ds.Tables[0];


    }
    }

    Help me to make it work

    Wednesday, July 4, 2012 2:24 AM

Answers

  • User1196771204 posted

    hi there,

    In order to run Crystal Report properly, there are several things you need to check:

    1. Please make sure the crsytal report version that you used on your code MATCHES the one you instal on the server
    2. Please make sure the crsytal report assemblies that you used on your code MATCHES the one you instal on the server 
    3. Please make sure you allow FULL TRUST mode on your site/application
    4. Please make sure you set the application pool to run under LOCAL SERVICE permission
    5. Please make sure you copy the crystalreportviewer folder to your working folder.

    For Crystal Report hosting, you can always contact asphostcentral.com. Thank heaps! 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2012 1:50 AM

All replies

  • User-661350001 posted

    one or more crystal report dlls are missing on the server, please retry to re-install crystal reports

    Wednesday, July 4, 2012 3:12 AM
  • User2059853125 posted

    I have reinstalled crystal reports, still its giving the same error.. :(

    Wednesday, July 4, 2012 4:13 AM
  • User132634151 posted

    Are you on a development server or on the server? If you are on the server, be sure to have all the files (the RPT in the right folder, in your case in the same folder as your aspx page.)

    Wednesday, July 4, 2012 9:01 AM
  • User2059853125 posted

    can u tell me what all files I need to save in the folder and rom where to download it.

    Thursday, July 5, 2012 3:13 AM
  • User132634151 posted

    Your SampleReport.rpt

    Also put your ReportViewer dll files in the \bin folder. ( 3 dll )

    And copy the folder crystalreportviewers13 ( maybe you will have a different number at the end if you use another version) in the aspnet_client\system_web\4_0....\

    Thursday, July 5, 2012 8:33 AM
  • User1196771204 posted

    hi there,

    In order to run Crystal Report properly, there are several things you need to check:

    1. Please make sure the crsytal report version that you used on your code MATCHES the one you instal on the server
    2. Please make sure the crsytal report assemblies that you used on your code MATCHES the one you instal on the server 
    3. Please make sure you allow FULL TRUST mode on your site/application
    4. Please make sure you set the application pool to run under LOCAL SERVICE permission
    5. Please make sure you copy the crystalreportviewer folder to your working folder.

    For Crystal Report hosting, you can always contact asphostcentral.com. Thank heaps! 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2012 1:50 AM