我有一个数据库,我想在我的报告中使用它的几个表(Crystal Report), 在我的代码中我有
testdbDataSet ds = new testdbDataSet();
testdbDataSetTableAdapters.ProductsTableAdapter productAdapter = new testdbDataSetTableAdapters.ProductsTableAdapter();
productAdapter.Fill(ds.Products);
testdbDataSetTableAdapters.RegionTableAdapter regionAdapter = new testdbDataSetTableAdapters.RegionTableAdapter();
regionAdapter.Fill(ds.Region);
ds.AcceptChanges();
ReportDocument reportDoc = new ReportDocument();
reportDoc.FileName = "CrystalReport1.rpt";
reportDoc.SetDataSource(ds);
crystalReportViewer1.ReportSource = reportDoc;
crystalReportViewer1.Show();
crystalReportViewer不显示我的报告
我已经检查了stackoverflow上的this链接,但无法完成此操作
答案 0 :(得分:0)
testdbDataSet ds = new testdbDataSet();
//FETCH FROM ANYWHERE TO a DataTable
DataTable _DtFrmDBPrd = new DataTable();
DataTable _DtFrmDBRgn = new DataTable();
_DtFrmDBPrd = GetDataFrmDBPrd();//Filling the DataTable From DB or any where..
_DtFrmDBRgn = GetDataFrmDBRgn();
ds.Products.Merge(_DtFrmDBPrd);//Both the Data Table should have the same column name and Data Type
ds.Region.Merge(_DtFrmDBRgn);
ReportDocument reportDoc = new ReportDocument();
reportDoc.FileName = "CrystalReport1.rpt";
reportDoc.SetDataSource(ds);
crystalReportViewer1.ReportSource = reportDoc;
crystalReportViewer1.Show();