Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello im having a little problem. Im using the following code trying to fill my crystal report.
As you can see the query is kind of dynamic i mean, the selected dates change and so the query change. When it load the report it comes out empty. I have tried adding the command to the report but i can just add static queries and they wont change when you change the selection, how can i do this.
string query = "SELECT movimientos.fecha, bancos.banco, cuentas.numero_cuenta, movimientos.pago, movimientos.cheque, movimientos.beneficiario, movimientos.referencia, categorias.categoria, conceptos.concepto, movimientos.retiro FROM movimientos INNER JOIN categorias ON movimientos.id_categoria=categorias.id  INNER JOIN conceptos ON movimientos.id_concepto=conceptos.id INNER JOIN cuentas ON movimientos.id_cuenta=cuentas.id INNER JOIN bancos ON movimientos.id_banco=bancos.id WHERE movimientos.id_categoria='" + conexion.categoria + "' AND movimientos.id_concepto='2' AND fecha BETWEEN '" + conexion.fecha1 + "' AND '" + conexion.fecha2 + "'";
     string mySqlString = query;
     myConnection.Open();
     MySqlDataAdapter da = new MySqlDataAdapter(mySqlString, myConnection);
     DataSet ds = new DataSet();
     da.Fill(ds);
     DataTable dt = new DataTable();
     dt = ds.Tables[0];

     ReportDocument rpt = new ReportDocument();
     string reportPath = Server.MapPath("CrystalCompras.rpt");
     rpt.Load(reportPath);
     CrystalReportViewer1.ReportSource = rpt;
Posted

1 solution

I see you create a datatable, and I see you open a report... but you don't seem to be passing the datatable to the report...
 
Share this answer
 
Comments
thatraja 31-May-11 21:30pm    
Correct, 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900