Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

Cannot create a data reader for dataset 'DatasetName' only when filtering by DateTime

$
0
0

Hello guys, 

I have a report in an aspx webform which I update dynamically with an sql command with filters. When the user click the button the query is built according the Textbox that the user filled. Everything works great excepting for the DateTime filters. Curiously in my local machine works perfectly, the problem only occurs when I put the code on the server. I can't figure out if there is a problem with the SQL version or the Datetime format, specially because the rest of the filters are working properly and even the Date filters works well on my Visual Studio.

private void GetReporteCustom(string command)
{
DataTable table = new DataTable();
table = sql.getDataTable(command);

ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dsReporteGeneral", table));
ReportViewer1.DataBind();
ReportViewer1.LocalReport.Refresh();
}


protected void ButtonFiltrar_Click(object sender, EventArgs e) { DateTime dateDesde = new DateTime(2017, 4, 1, 0, 0, 0); DateTime dateHasta = DateTime.Now; if (TextBoxFechaDesde.Text != "") { dateDesde = DateTime.Parse(TextBoxFechaDesde.Text); } if (TextBoxFechaHasta.Text != "") { dateHasta = DateTime.Parse(TextBoxFechaHasta.Text); } //GetReportByDate(date); string com = ""; com = "SELECT oper.id as ID, oper.codigo AS Codigo, rem.nombre AS Remitente, dest.nombre AS Destinatario, oper.hora_reg, oper.hora_ret, oper.bandeja_sal AS Bandeja_Sal, oper.hora_pal, oper.operador_pal, oper.hora_pal2, oper.operador_pal2, oper.hora_pal3, oper.operador_pal3, oper.hora_salida, oper.operador_sal, oper.hora_salida2, oper.operador_sal2, oper.hora_salida3, oper.operador_sal3, oper.hora_fin, sec.descripcion as Sector, pal.descripcion as Palomar, oper.envio, oper.operador, oper.paquete, est.estado as Estado, DATEDIFF(hh, oper.hora_reg, GetDate()) as Tiempo " +"from dbo.operaciones AS oper, dbo.remitente as rem, dbo.remitente as dest, dbo.sector as sec, dbo.palomar as pal, dbo.estado as est " +"where rem.id = oper.remitente and dest.id = oper.destinatario and sec.id = oper.sector and pal.id = oper.palomar and oper.estado = est.id"; if (TextBoxFechaDesde.Text != "") { com += " AND oper.hora_reg >= '" + dateDesde + "'"; } if (TextBoxFechaHasta.Text != "") { com += " AND oper.hora_reg <= '" + dateHasta + "'"; } if (TextBoxCodigo.Text != "") { com += " AND oper.codigo LIKE '" + TextBoxCodigo.Text + "%'"; } if (DropDownListTipo.SelectedValue != "Todos") { com += " AND oper.paquete LIKE '" + DropDownListTipo.SelectedValue + "%'"; } if (TextBoxOperador.Text != "") { com += " AND oper.operador LIKE '" + TextBoxOperador.Text + "%'"; } if (DropDownListEnvio.SelectedValue != "Todos") { com += " AND oper.envio LIKE '" + DropDownListEnvio.SelectedValue + "%'"; } if (TextBoxPrecinto.Text != "") { com += " AND oper.precinto LIKE '" + TextBoxPrecinto.Text + "%'"; } if (TextBoxDestinatario.Text != "") { com += " AND dest.nombre LIKE '" + TextBoxDestinatario.Text + "%'"; } if (TextBoxRemitente.Text != "") { com += " AND rem.nombre LIKE '" + TextBoxRemitente.Text + "%'"; } GetReporteCustom(com); } }




Viewing all articles
Browse latest Browse all 1418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>