none
Crystal Report exception "The report has no tables" RRS feed

  • Question

  • Hi,

    I am using CR 10.5 with VS 2008 for the first time. The SQL query I am using is dynamic in the sense that it displays different Database fields according to a user input (from a join of many Tables). The query result will be displayed with CR. For such, I didi the following:
    1) I stored the query as a view (mview).

    2) I created a blank report (CrystalReport.rpt).

    3) I instantiated a ReportDocument object (mReportDocument).

    4) I instantiated an OleDbDataAdapter (oleAdapter) object to fill a Dataset object  (dataset).

    5) I loaded the report File to the ReportDocument object

    6) I set the ReportDocument object's Dataset object to my created dataset objec.

    7) I bind the viewer created object (CrystalReportViewer1) with my ReportDocument Object

    Below is part og my code followed by the exception displayed text.

    I am stuck with this exception for almost one week and I have tried all what I have found in this Forum or in the Internet. I have also applied VS SP1.

    Any help will be very appreciated.

    Kindly.



    protected
    void Page_Load(object sender, EventArgs e)

     

    ReportDocument mRepDocument = new ReportDocument();

     

     

    OleDbConnection oleConn = new OleDbConnection(@"Provider=SQLOLEDB; Data Source=(LOCAL) ; Initial Catalog=northwind ; Integrated Security=SSPI");

     

     

    OleDbDataAdapter oleAdapter = new OleDbDataAdapter();

     

     

    string query = "SELECT * FROM mview";

    oleAdapter.SelectCommand =

     

    new OleDbCommand(query, oleConn);

     

     

    //try

     

    //{

     

    //Connect to the data source, fetch the data, and disconnect

     

    // from the database.

     

    DataSet dataSet = new DataSet();

    oleAdapter.Fill(dataSet,

     

    "mview");

     

     

    // Pass the populated data set to the report.

    mRepDocument.Load(

    @"C:\Projects\C#ProgramExamples\CrystalReport-Form-ReportDocument-Ex1\CrystalReport.rpt");

     

    CrystalReportViewer1.ReportSource = mRepDocument;

     

    //}

     

    //catch (Exception ex)

     

    //{

     

    // Label2.Text = ex.Message;

     

    //} 

    }


    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: CrystalDecisions.CrystalReports.Engine.DataSourceException: The report has no tables.

    Source Error:

    Line 39:             // Pass the populated data set to the report.
    Line 40:             mouradRepDocument.Load(@"C:\Projects\EducationMinistry\C#ProgramExamples\CrystalReport-Form-ReportDocument-Ex1\CrystalReport.rpt");
    Line 41:             mouradRepDocument.SetDataSource(dataSet);
    Line 42:             //mouradClassDocument.FileName = @"C:\Projects\EducationMinistry\C#ProgramExamples\CrystalReport-Form-ReportDocument-Ex1\CrystalReport.rpt";
    Line 43:             //mouradClassDocument.SetDataSource(dataSet);

    Source File: c:\Projects\EducationMinistry\C#ProgramExamples\CrystalReport-Form-ReportDocument-Ex1\Default.aspx.cs    Line: 41

    Stack Trace:

    [DataSourceException: The report has no tables.]
       CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type) +180
       CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet) +66
       _Default.Page_Load(Object sender, EventArgs e) in c:\Projects\EducationMinistry\C#ProgramExamples\CrystalReport-Form-ReportDocument-Ex1\Default.aspx.cs:41
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    

    mRepDocument.SetDataSource(dataSet);

    {

     

    Thursday, December 17, 2009 3:15 PM

Answers

  • Hi,

       If you will try to remove any column that is available in your CR but not in your Dataset/Datatable, you will get a run time error. Better add all those columns in your dataset/datatable that is there in your CR.

     

     

    If you are satisfied with the answer, please mark it as answer so that other people can avail the advantage through this thread.


    Aftab Ansari
    • Marked as answer by moumou Sunday, December 20, 2009 8:55 AM
    Friday, December 18, 2009 7:52 AM

All replies

  • Hi, Look into your point: 2. In your report, there is no table as you have mentioned ‘2) I created a blank report (CrystalReport.rpt).’. So in this case, if you try to set datasource to reportDocument object that referenced to CrystalReport.rpt which is blank report, you will get an error (Line 41: mouradRepDocument.SetDataSource(dataSet);). Because CrystalReport.rpt does not contain any command/Table. As you are trying to show your report dynamically from different database. In this case, you should make your report with all possible columns. Once report ready with all possible columns, you need to manage all these columns in dataset/datatable at time of datasource binding.
    Aftab Ansari
    Thursday, December 17, 2009 3:47 PM
  • Hi,

    Thanks for your reply and your hints. 

    I tried what you adviced me and it worked. I have now to remove, at run-time, the unused fields from the report and to re-arrange the existing fields (also from the report) to occupy all the report's space. I hope that CR allows me to access its fields with the possibility to remove/move some of them at run-time.

    Again, thanks so much.

    Sincerly. 
    Friday, December 18, 2009 7:10 AM
  • Hi,

       If you will try to remove any column that is available in your CR but not in your Dataset/Datatable, you will get a run time error. Better add all those columns in your dataset/datatable that is there in your CR.

     

     

    If you are satisfied with the answer, please mark it as answer so that other people can avail the advantage through this thread.


    Aftab Ansari
    • Marked as answer by moumou Sunday, December 20, 2009 8:55 AM
    Friday, December 18, 2009 7:52 AM
  • Hi friends

    I have a same problem.i have a blank CR and i dont know which controls should i add to my blank CR .Any help would be appreciated.

    Thank you

    Sunday, June 20, 2010 1:10 PM