查询的那一部分我已经做好了,绑定的是datagridview控件...想把查询出来的结果生成一个报表,应该怎么弄呢?我只会新建一个窗体拉个crystalReportViewer控件把表中的所有数据生成报表
解决方案 »
- 求个存储方案
- axWindowsMediaPlayer怎样隐藏控制条
- const的byte数组定义问题
- 我的代码有点问题 请大家帮忙看下。
- 急!如何修改Webclient.header属性的Date值啊,使用add方法和AddWithoutValidate 出现"此标头必须使用适当的属性进行修改"错误
- 简单问题,combobox控件如何只允许选择而不可以输入?谢谢各位!
- 关于命名规范:
- 执行存储过程的问题?
- 在c#中如何调用别的语言写的dll库啊?(比如c++)
- cmsoft(韦小宝是我的老乡)有请——〉
- 求助:The following exception occurred in the DataGridView
- datagridview控件
最重要的是用那种方式做水晶报表,下面的用推式方法写的,把查询出来的结果重新绑定给数据集就可以了.string strConnString = @"Data Source=Q-LUOLISHUANG/SQLEXPRESS;Initial Catalog=myDatabase;User Id=sa;Password=luols;";
SqlConnection conn = new SqlConnection(strConnString);
//这里为了和数据集里的列名保持一致,特别用as取了别名
//务必保持一致!!
string strSQL = "select c1 as Col1,c2 as Col2,c3 as Col3 from myTable"; //原始数据传给报表,让报表去处理
SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);
DataSet1 myDataSet = new DataSet1();
da.Fill(myDataSet.DataTable2); //把查询到的数据“塞”到数据集
CrystalReport1 myReport = new CrystalReport1();
myReport.SetDataSource(myDataSet);
crystalReportViewer1.ReportSource = myReport;
string strSQL = "select ID as Col1,jine as Col2,riqi as Col3 from detail3"; //原始数据传给报表,让报表去处理
SqlDataAdapter sda = new SqlDataAdapter(strSQL, conn);
DataSet ds = new DataSet(); //实例化DataSet对象
sda.Fill(ds); //使用SqlDataAdapter对象的Fill方法填充DataSet bb myReport = new bb();
myReport.SetDataSource(ds);
crystalReportViewer1.ReportSource = myReport;
string strSQL = "select 编号=ID,日期=riqi,金额=jine,事件=shijian from detail3 where riqi like '%" + textBox1.Text + "%' and jine like '%" + textBox2.Text + "%' and shijian like'%" + textBox3.Text.Trim() + "%' and shouzhi like'%" + comboBox1.Text.Trim() + "%'and yonghu ='" + Names + "'"; //原始数据传给报表,让报表去处理
SqlDataAdapter sda = new SqlDataAdapter(strSQL, conn);
DataSet ds = new DataSet(); //实例化DataSet对象
sda.Fill(ds); //使用SqlDataAdapter对象的Fill方法填充DataSet bb myReport = new bb();
myReport.SetDataSource(ds);
crystalReportViewer1.ReportSource = myReport;
bb myReport = new bb(); //这一句是什么呀? 应试是这样
CrystalReport1 myReport = new CrystalReport1(); myReport.SetDataSource(ds);
crystalReportViewer1.ReportSource = myReport;
bb是我的报表名称,我猜也是我水晶报表直连数据库的问题,能告诉我一声应该怎么建这个报表吗?
http://topic.csdn.net/u/20090626/18/0e7d0af0-2555-479d-9cb5-84175787f2cd.html
指向报表文件存放路径而矣!