Solved

The CrystalReport  has no tables

Posted on 2010-11-20
2
620 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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