ASP Crystal Report No Tables Reported

I am trying to create a program in which I put Datatable data in 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();

On the aspx page:

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

Trtp.rpt I have chosen empty enter image description here

Error in this line

report_doc.SetDataSource(ds.Tables[0]);

Mistake:

The report has no tables

This is the first time I'm trying to create a program that uses a crystal report, so I don’t know about it.

Why am I getting this error?

thanks

+4
source share
1 answer

I got a work program. I need to create a dataset page with a datatable with columns in it. Now bind Dataset to Crystal report to make it work.

0
source

Source: https://habr.com/ru/post/1621376/


All Articles