1
votes

I'm setting up a crystal report for my table, i followed all the instruction to fix the load report failed, giving full control permission to temp folder even the file path and still have an error : Load Report Failed, 'CrystalDecisions.Shared.CrystalReportsException'

Here is my code

public ActionResult OccupiedReport()  
    {
        List<ReservationModel.OccupiedStatus> Occupied = new List<ReservationModel.OccupiedStatus>();
        string constr = ConfigurationManager.ConnectionStrings["MyCnn"].ConnectionString;
        using (MySqlConnection con = new MySqlConnection(constr))
        {
            string query = "SELECT * FROM room_status WHERE check_out >= CURDATE() and status ='occupied'";
            using (MySqlCommand cmd = new MySqlCommand(query))
            {
                cmd.Connection = con;
                con.Open();
                using (MySqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        Occupied.Add(new ReservationModel.OccupiedStatus
                        {
                            DormName = sdr["Dorm_Name"].ToString(),
                            RoomNumber = sdr["Room_Number"].ToString(),
                            BedNumber = sdr["Bed_Number"].ToString(),
                            GuestName = sdr["Guess_Name"].ToString(),
                            Classification = sdr["Classification"].ToString(),
                            Gender = sdr["Gender"].ToString(),
                            CheckIn = sdr["Check_In"].ToString(),
                            CheckOut = sdr["Check_Out"].ToString(),
                            StatusType = sdr["Status"].ToString()
                        });
                    }

                }
                con.Close();
                ReportDocument rd = new ReportDocument();
                rd.FileName = Server.MapPath("/CrReport/CrystalReport1.rpt");
                rd.Load(Server.MapPath("~/CrReport/CrystalReport1.rpt"));
                rd.SetDataSource(Occupied);

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();


                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return File(stream, "application/pdf", "CustomerList.pdf");

            }
        }


    }  

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

Additional information: Load report failed.

1

1 Answers

0
votes

Sound like it either problems with report path, try the suggestion here : code project

Or if that's not the problem, is there more than one version of CR installed in the machine ? because that causes problems like this one. Try to unistall and install the correct version again.