我正在为我的表设置水晶报表,我按照所有说明修复了加载报表失败,对temp文件夹甚至文件路径提供了完全控制权限,但仍然出现错误:加载报表失败,'CrystalDecisions .Shared.CrystalReportsException'
这是我的代码
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");
}
}
}
CrystalDecisions.CrystalReports.Engine.dll中发生了类型'CrystalDecisions.Shared.CrystalReportsException'的异常,但未在用户代码中处理
其他信息:加载报告失败。
答案 0 :(得分:0)
听起来好像报告路径有问题,请在这里尝试建议:code project
或者,如果那不是问题,那么计算机中是否安装了多个版本的CR?因为那会引起类似这样的问题。尝试取消安装并重新安装正确的版本。