Crystal Reports populating problem
Dear friends,
I want to populate dataset and display it into Crystal report viewer. I am working in c# in Visual Studio 2005. I have even draged and drop crystal reportviewer control. But the error it is giving "The report has no tables." and point to dataset Even though by placing break point I am able to see data in dataset.
Following is the code:
String conn = "Provider = Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=sma;Data Source = dbbusiness.mdb";
OleDbConnection Connection = new OleDbConnection(conn);
Connection.Open();
DataSet dataReport1 = new DataSet();
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("SELECT item,quantity,price FROM sales WHERE billno='" + textBox1.Text + "'", Connection);
myDataAdapter.Fill(dataReport1, "sales");
DataTable dtable = new DataTable("sales");
dataReport1.Tables.Add();
CrystalReport1 oRpt = new CrystalReport1();
oRpt.SetDataSource(dataReport1);
crystalReportViewer1.Visible = true;
crystalReportViewer1.ReportSource = oRpt;
Connection.Close();
Please help me.
iinfPosted Nov 30, 2006, 9:20 AM
You are correct. I mistakengly changed the case of one letter.
Mahesh ChandPosted Nov 25, 2006, 8:39 AM
dataReport1.Tables.Add();
Also how did you generate your report? Did you direct connect to the database and generated the report. You may want to look at my articles in Crystal Reports section on how to generate reports from a DataSet.
The reason you get "Table not available" error b/c the datasource you used to create the report is different than the datasource you are passing to the report dynamically.