[英]ASP Crystal Report The report has no tables
I am trying to make a program where I put the data of a Datatable in a Crystal Report. 我正在尝试创建一个程序,我将数据表的数据放在Crystal Report中。 Here is the code:
这是代码:
ReportDocument report_doc = new ReportDocument();
report_doc.Load(Server.MapPath("Trtp.rpt"));
string[] columns = new string[] { "col1", "col2", "col3", "col110", "col111" };
DataTable dt = new DataTable();
int count = columns.Count();
for (int i = 0; i < count; i++)
dt.Columns.Add(columns[i], typeof(string));
myConnection.comm.CommandText = @"select col1,col2,col3.col110,col111 from TabledataT where " + query;
myConnection.reader = myConnection.comm.ExecuteReader();
dt.Load(myConnection.reader);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
report_doc.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = report_doc;
CrystalReportViewer1.RefreshReport();
In the aspx page : 在aspx页面中:
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
Trtp.rpt I have selected blank Trtp.rpt我选择了空白
Error is on this line 错误就在这一行
report_doc.SetDataSource(ds.Tables[0]);
Error : 错误:
The report has no tables
This is the first time I am trying to create the program which uses crystal report, so dont have much knowledge about it. 这是我第一次尝试创建使用水晶报表的程序,因此对此没有太多了解。
Why I am getting this error ? 为什么我收到此错误?
Thanks 谢谢
I got the working program. 我得到了工作计划。 I need to create a dataset page with datatable with columns in it.
我需要创建一个数据集页面,其中包含带有列的数据表。 Now Bind the Dataset to the Crystal report to make it working.
现在将数据集绑定到Crystal报表以使其正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.