I am trying to send the data from a single record to a Crstal Report that I created and then create a PDF from that report that I can Print. This is the error message that i get
Exception Details: CrystalDecisions.CrystalReports.Engine.DataSourceException: The data source object is invalid.
Can anyone help me this this?
Thank You
This is the ActionResult that I created.
public ActionResult ExportReport(int? id)
{
InjuryIllness i = db.InjuryIllnesses.Find(id);
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Reports"), "Report_InjuryIllness.rpt"));
rd.SetDataSource(i);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
try
{
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "Report_InjuryIllness.pdf");
}
catch (Exception ex)
{
throw;
}
}