I created one simple Crystal Report
DataSet ds = new DataSet();
BL obj = new BL();
ds = obj.get_student();
DataTable dt = new DataTable();
if (ds != null)
if (ds.Tables.Count > 0)
if (ds.Tables[0].Rows.Count > 0)
{
try
{
CrystalDecisions.CrystalReports.Engine.
ReportDocument obj1 = new CrystalDecisions.CrystalReports.Engine.ReportDocument();obj1.Load(
"F:\\Jeevan_Data\\AssetReports\\AssetReports\\CrystalReport1.rpt");dt = ds.Tables[0];
obj1.SetDataSource(dt);
crystalReportViewer1.ReportSource = obj1;
}
catch(Exception ex){
MessageBox.Show(ex.Message);}
}
But i getting this error: The report has no tables.
But Dataset having 5rows ,tell me the how to bind data to crystal report
Aminul IslamPosted Sep 16, 2012, 10:28 PM
rpt1.Database.Tables["myTable"].SetDataSource(myDataTable);
crystalReportViewer1.ReportSource = rpt1;
crystalReportViewer1.Visible = true;
crystalReportViewer1.Refresh();
I can view a blank report after an error[Invalid index. (Exception from HRESULT: 0x800200B (DISP_E_BADINDEX))] And there are no data in my crystal report. I would like to add my dataTable data in crystal report. I have tried Database Field->Database Expert->Select all available data sources but din't get myDataTable.
Please help me to know "How would i add myDataTable values in my crystal report.
[I use VS2008 and in this project i don't have any database. I only need to view dataTable values in my report.]
Thanks in advance
Aminul
jeevan mummadiPosted Sep 30, 2008, 2:00 AM
thank u farooq
Muhammad Shahid FarooqPosted Sep 29, 2008, 2:19 PM
Write this line of code
obj1.Database.Tables[0
].SetDataSource(dt);instead of
obj1.SetDataSource(dt);