简体   繁体   English

如何修复水晶报表中加载报表失败

[英]How to fix Load report failed in crystal report

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'我正在为我的表设置一个水晶报告,我按照所有说明修复加载报告失败,给予临时文件夹甚至文件路径的完全控制权限,但仍然有错误:加载报告失败,'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 CrystalDecisions.CrystalReports.Engine.dll 中出现类型为“CrystalDecisions.Shared.CrystalReportsException”的异常,但未在用户代码中处理

Additional information: Load report failed.附加信息:加载报告失败。

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 ? 或者,如果这不是问题,那么计算机中是否安装了多个版本的CR? because that causes problems like this one. 因为那会引起类似这样的问题。 Try to unistall and install the correct version again. 尝试取消安装并再次安装正确的版本。

I experienced same issue.我遇到了同样的问题。 ON Server it loads report but after sometime it generate this error.After Restarting IIS Application Error resolve and then it comes again.在服务器上它加载报告但一段时间后它生成此错误。重新启动后 IIS 应用程序错误解决然后它再次出现。 This occur randomly.Following document help me to resolve my issue Solving The “Load Report Failed” Error这是随机发生的。以下文档帮助我解决我的问题解决“加载报告失败”错误

Crystal Report Document needs to be manually disposed.You need to close Report document. Crystal Report Document需要手动处理,需要关闭Report document。 It actually creates temprary files in Windows Temp Folder它实际上在 Windows 临时文件夹中创建临时文件

You should control the lifetime of all Reports in your application and call their Dispose before reaching the 75 limit.您应该控制应用程序中所有报告的生命周期,并在达到 75 个限制之前调用它们的 Dispose。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM