Local report RDLC to PDF Is there any way to improve the performance of local report or even an alternative if not? I have been looking for a solution for quite some time but the general consensus seems to be that it's just slow.

public byte[] genReportBytes(int id, string fromm,string too,string filetype)
{
    reportDetails repD = new reportDetails();
    repD = getOneReport(id);

    LocalReport report = new LocalReport();

    if (fromm != null)
        repD.ParametersCommandLine = "@startdate=" + fromm;

    if (too != null)
        repD.ParametersCommandLine += " @enddate=" + too;

    string RDLCPath = ConfigurationManager.AppSettings["RDLCPath"];
    string ReportOutputPath = ConfigurationManager.AppSettings["ReportOutputPath"];

    string RDLCName = repD.RDLCName;
    RDLCPath += @"\" + RDLCName;
    report.ReportPath = RDLCPath;

    string sqlGet = repD.SQLOfReport;

    report.DataSources.Add(new ReportDataSource(repD.DatasetName, getReportData(sqlGet, repD.ParametersCommandLine)));

    // export to byte array

    Warning[] warnings;
    string[] streamids;
    string mimeType;
    string encoding;
    string filenameExtension;
    string deviceInf = "";
    byte[] bytes;
    string extension;

    if (filetype == "pdf")
    {
        deviceInf = "&lt;DeviceInfo&gt;&lt;PageHeight&gt;8.5in&lt;/PageHeight&gt;&lt;PageWidth&gt;11in&lt;/PageWidth&gt;&lt;MarginLeft&gt;0in&lt;/MarginLeft&gt;&lt;MarginRight&gt;0in&lt;/MarginRight&gt;&lt;/DeviceInfo&gt;";
        //fileName = ReportOutputPath + @"\" + repD.NameOfOutputPDF + ".PDF";
        bytes = report.Render("pdf", deviceInf, out mimeType, out encoding, out filenameExtension,
        out streamids, out warnings);
    }
    else
    {
        //fileName = ReportOutputPath + @"\" + repD.NameOfOutputPDF + ".XLS";
        bytes = report.Render(
              "Excel", null, out mimeType, out encoding,
               out extension,
              out streamids, out warnings);
    }

    return bytes;
}
Your naming conventions are hard to follow, or you're not following them; either way, you're not following the standard/recommended/established conventions.

public byte[] genReportBytes(int id, string fromm,string too,string filetype)


Public members should be PascalCase; locals and parameters should be camelCase. That would make the signature read like this:

public byte[] GenReportBytes(int id, string fromm, string too, string fileType)


getOneReport(id) would be GetOneReport(id), and getReportData(sqlGet, repD.ParametersCommandLine)) would be GetReportData(sqlGet, repD.ParametersCommandLine)), and streamids would be streamIds.

But if I had to pick only 1 name to change, it would be this one:

reportDetails repD = new reportDetails();


reportDetails is a TYPE and should be PascalCase like every single other type name in the framework. Notice how that one even gets the syntax highlighter confused?



The filetype parameter is stringly typed, and wants to be an enum. And I don't understand the doubling-up of m in fromm and o in too - if that's just to make from and to usable names, you have two options:


Prefix with a @ verbatim specifier, making them @from and @to. Seriously though, don't do that.
Give them a meaningful name; I'd match them with the parameters they're mapped to, so that would be startDate and endDate.




There are other points to add, but I have to go... will come back and edit this answer if no one else points them out by then.