Solved

The CrystalReport  has no tables

Posted on 2010-11-20
2
617 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
Comment Utility
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
Comment Utility
thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

12 Experts available now in Live!

Get 1:1 Help Now