Print Page | Close Window

error that says "The report has no tables".

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4951
Printed Date: 25 Apr 2024 at 11:02pm


Topic: error that says "The report has no tables".
Posted By: eswaran
Subject: error that says "The report has no tables".
Date Posted: 08 Dec 2008 at 4:36am

  Hi all,

I am developing windows application. In this application I need to use the crystal report. I need to add the fields by programmatically. I am using dataset to bind the table values with crystal report. But when I set the datasource value to the crystalreport i am getting error that says "The report has no table". How to solve this? Here, I attached my code.

private void Form1_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = databaseconnectionstring;

           StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT ");
            sbSql.Append("Face_page.[Case], Face_page.Type, Face_page.Location, Face_page.Flag, ");
            sbSql.Append("Face_page.Officer, Face_page.ID, Face_page.Written, Face_page.Shift, ");
            sbSql.Append("Face_page.DaysOff ");           
            sbSql.Append("FROM ");
            sbSql.Append(" Face_page ");           
            sbSql.Append(" where ");
            sbSql.Append("Face_page.[Case] = '71-111-1111E'");

            string sql = sbSql.ToString();
            DataSet ds = new DataSet();         
                       
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
           
            da.Fill(ds, "sample");          

            CrystalReport4 cryReport1 = new CrystalReport4();          
           
            if(ds.Tables.Count>0) {
                cryReport1.SetDataSource(ds.Tables[0]); // ----> I am getting error here..
            }
            crystalReportViewer1.Visible = true;
            this.crystalReportViewer1.ReportSource = cryReport1;
            con.Close();
        }



-------------
R. Eswaran



Print Page | Close Window