Solved

The CrystalReport  has no tables

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now