My database is MySQL, so my reports are RDLC. Both use the same xml, but RDLC allows you to have neither the connection nor the query. This way I do the query and connection to the bank via C # and send to the RDLC as a DataSource that issues it is in charge of generating and issuing the report.
You can convert RDL to RDLC: link
This done, create a basic function to issue your reports directly in ResponseStream, type this:
private void Renderizar(string nomeReport, Formato formato, Dictionary<string, object> dataSources, Dictionary<string, object> parameters = null)
{
var deviceInfo = string.Format("<DeviceInfo>" + " <OutputFormat>{0}</OutputFormat>" + "</DeviceInfo>", "PDF"|"Excel");
var report = new LocalReport();
using (IO.StreamReader arquivo = new IO.StreamReader(Server.MapPath(string.Format("~/Relatorios/{0}.rdlc", nomeReport)))) {
var strre = arquivo.ReadToEnd();
report.Refresh();
report.LoadReportDefinition(new IO.StringReader(strre));
}
foreach (var item in dataSources) {
var DataSource = new ReportDataSource(item.Key, item.Value);
report.DataSources.Add(DataSource);
}
List<ReportParameter> @params = new List<ReportParameter>();
if (parameters != null) {
@params = new List<ReportParameter>();
foreach (var item in parameters) {
@params.Add(new ReportParameter(item.Key, item.Value.ToString()));
}
}
string mimeType = "";
string ext = "";
string encoding = "";
Warning[] warnings = null;
string[] streams = null;
if (@params != null) {
report.SetParameters(@params);
}
var bytes = report.Render(formato.ToString(), deviceInfo, out mimeType, out encoding, out ext, out streams, out warnings);
Response.ContentType = mimeType;
Response.BinaryWrite(bytes);
}
Then to call I use:
var dataSources = new Dictionary<string, object>();
dataSources.Add("DataSourceNameDENTRO_DO_REPORT", List<Objetos>);
var parametros = new Dictionary<string, object>();
parametros.Add("Data", "VALOR PARA EXIBIR COMO UM PARAMETRO NO REPORT");
Renderizar("NomeRelatorio", "PDF", dataSources, parametros);