该报告没有表格 [英] The report has no table

查看:81
本文介绍了该报告没有表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



请帮助我,我的项目有问题..

我想要报告和尝试很多方法,现在我正在使用Crystal报告,我希望它直接从datagridview读取,所以我把它放在数据表中,在数据集中并添加到水晶报告但是错误确认它说报告已经没有表格

我的数据gridview有数据肯定所以该怎么办

请求我的Ur建议

这是代码

Hi,

Please help me I ''ve problem in my project..
I want to make report and try alot of ways , now i am using Crystal report and i want it to read from datagridview directly , so i put it in datatable ,in dataset and added to crystal report but an error accure it say "THE REPORT HAS NO TABLE"
My data gridview has data am sure so what to do
Plese i want Ur advice
this is the code

Dataset gridviewds; 
ON click on report button
{
DataTable dt = new DataTable("gridviewtable");
         
            foreach (DataGridViewColumn col in dataGridView1.Columns)
            {
                dt.Columns.Add(col.HeaderText);
            }

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataRow dRow = dt.NewRow();
                foreach (DataGridViewCell cell in row.Cells)
                {
                    dRow[cell.ColumnIndex] = cell.Value;
                }
                dt.Rows.Add(dRow);

            }
            gridviewds = new DataSet(); 
            gridviewds.Tables.Add(dt); 
            CrystalReport3 cr = new CrystalReport3();
           cr.SetDataSource(gridviewds.Tables["gridviewtable"]);// here it says the report has no tables 
            Print pf = new Print();// here is my crystal report viewer
            pf.Show();
}



这是我的代码,请告诉我哪里错了.... ???


This is my code exactly please tell my where is the wrong....???

推荐答案

您需要获取数据集或数据表中的表,然后在水晶报表中调用它。您不能将datagridview用于水晶报告。



You need the get the table in a dataset or datatable and then call it in crystal report. You cannot use datagridview for crystal report.

CrystalReport3 cr = new CrystalReport3();
          cr.SetDataSource(dt)//Where dt is the datatable object.;





谢谢



Thanks


这篇关于该报告没有表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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