Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

The CrystalReport  has no tables

Posted on 2010-11-20
2
Medium Priority
?
624 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
abdkhlaif earned 1000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

604 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