我已经阅读了错误的所有潜在解决方案(无法为数据集创建数据读取器)到目前为止还没有工作是我的代码片段(正确的参数正在传入数据):
public void GenerateRDLC(Finteq.Types.ReportingServices.ReportParameters p_ReportParameters, Stream p_ReportDefinition, ref string p_ReportOutput)
{
try
{
ReportViewer reportViewer = new ReportViewer();
DataTable customDataTable = new DataTable();
string mimeType = string.Empty;
string encoding = string.Empty;
string fileExtension = string.Empty;
string filetype = string.Empty;
string[] streamIDs;
Warning[] warnings = null;
//reportViewer.SizeToReportContent = true;
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.LoadReportDefinition(p_ReportDefinition);
reportViewer.localReport.DataSources.Clear();//added
reportViewer.LocalReport.DataSources.Add(new ReportDataSource(p_ReportParameters.ReportName, p_ReportParameters.ReportDataSource));
reportViewer.localReport.DataSources.Refresh; // added
string deviceInfo = "<DeviceInfo><OutputFormat>PDF</OutputFormat></DeviceInfo>";
byte[] reportFile;
try
{
reportFile = reportViewer.LocalReport.Render(p_ReportParameters.ReportFormat.ToString(), deviceInfo, out mimeType, out encoding, out fileExtension, out streamIDs, out warnings);
using (FileStream fileStream = new FileStream(p_ReportParameters.ReportTemplateFullPath, FileMode.Create))
{
fileStream.Write(reportFile, 0, reportFile.Length);
p_ReportOutput = p_ReportParameters.ReportTemplateFullPath;
}
}
catch (Exception ex)
{
throw new Exception("Failed to render local report, details: " + ex.Message + "Inner Exception: " + ex.InnerException);
}
}
catch (Exception exception)
{
throw new Exception("Generate_RDLC_Report::GenerateRDLC - " + exception.Message);
}
}
}
}