An error occurred during report processing. -RLDC reporting in ASP.NET MVC

Have you try like this after adding a TableAdapter? It is working perfectly for me.

public FileResult Report(string id)
{
    PersonTableAdapter ta = new PersonTableAdapter();
    PersonDataSet ds = new PersonDataSet();

    //for avoiding "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." error
    ds.Person.Clear();
    ds.EnforceConstraints = false;

    ta.Fill(ds.Person, id); //You might customize your data at this step i.e. applying a filter

    ReportDataSource rds = new ReportDataSource();
    rds.Name = "ReportingDataSet";
    rds.Value = ds.Person;

    ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer();
    rv.ProcessingMode = ProcessingMode.Local;
    rv.LocalReport.ReportPath = Server.MapPath("~/Report/Person.rdlc");

    // Add the new report datasource to the report.
    rv.LocalReport.DataSources.Add(rds);
    rv.LocalReport.EnableHyperlinks = true;
    rv.LocalReport.Refresh();

    byte[] streamBytes = null;
    string mimeType = "";
    string encoding = "";
    string filenameExtension = "";
    string[] streamids = null;
    Warning[] warnings = null;

    streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

    return File(streamBytes, mimeType, "Person" + "_" + id + ".pdf");
}

Hope this helps…

Leave a Comment