简体   繁体   中英

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. 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 :

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />

Trtp.rpt I have selected blank 在此输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM