如何解决水晶报表和查询? [英] how to solve Crystal Reports and Queries?

查看:84
本文介绍了如何解决水晶报表和查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个小问题.我正在使用以下代码尝试填充我的水晶报表.
如您所见,查询是动态的,我的意思是,所选日期会更改,因此查询也会更改.加载报告时,报告为空.我已经尝试将命令添加到报告中,但是我只能添加静态查询,并且当您更改选择时它们不会更改,我该怎么做.

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;

推荐答案

我看到您创建了一个数据表,并且看到您打开了一个报表...但是您似乎没有将数据表传递给报告...
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...


这篇关于如何解决水晶报表和查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆