Solved

The CrystalReport  has no tables

Posted on 2010-11-20
2
621 Views
Last Modified: 2012-08-14
Hi,

Here is some code I am using to display the report. I getting an
error saying "The report has no tables."



  protected void btnExport_Click(object sender, ImageClickEventArgs e)
    {
        CrystalReport cr = new CrystalReport();
        DataTable dt = new DataTable();
        dt.Columns.Add("Column 1", typeof(string));
        dt.Columns.Add("Column 2", typeof(string));

        //generate some random data in the datatable
        Random rnd = new Random();
        for (int i = 0; i < 100; i++)
        {
            dt.Rows.Add(rnd.Next(1, 1000000).ToString(), rnd.Next(1, 1000000).ToString());
        }

        string strReportPath = "CrystalReport.rpt"; // the path of  CrystalReport
        cr.Load(strReportPath);
        cr.SetDataSource(dt);
    }


My question is how can I add a table to the report within the code??

Thanks,
0
Comment
Question by:wael_shehab
2 Comments
 
LVL 3

Accepted Solution

by:
abdkhlaif earned 250 total points
ID: 34179629
Load fails because the report file "CrystalReport.rpt" has no tables.
you cannot add tables to a report, but you can fill existing tables with data.
for your code to work, you must have a table in the file "CrystalReport.rpt" with exactly the same columns as you defined for dt

one more thing, use ReportDocument instead of CrystalReport
0
 

Author Comment

by:wael_shehab
ID: 34182255
thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question