Tech Tips
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Load Report Failed

Go down

Load Report Failed Empty Re: Load Report Failed

Post  Admin Tue Mar 01, 2022 9:50 am

Following document help me to resolve my issue Solve Error
Crystal Report Document needs to be manually disposed.You need to close Report document. It actually creates temprary files in Windows Temp Folder

You should control the lifetime of all Reports in your application and call their Dispose before reaching the 75 limit.

Admin
Admin

Posts : 60
Join date : 2009-06-05

https://softro.forumotion.net

Back to top Go down

Load Report Failed Empty Load Report Failed

Post  Admin Tue Mar 01, 2022 9:48 am

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");

            }
        }


    } 
ON Server it loads report but after sometime it generate this error.After Restarting IIS Application Error resolve and then it comes again

Admin
Admin

Posts : 60
Join date : 2009-06-05

https://softro.forumotion.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum