2016-03-23 98 views
0

我有一个数据表,我从一个sql适配器中填充。我能够让它成功显示在datagridview中,但是当我尝试执行reportviewer时,它无法正常工作。将DataTable加载到ReportViewer中

DataTable dt = new DataTable(); 
dt.TableName = "SwipeReport"; 
da.Fill(dt); 

reportViewer1.Reset(); 
reportViewer1.ProcessingMode = ProcessingMode.Local; 
reportViewer1.LocalReport.ReportEmbeddedResource = "POC1.SwipeReport.rdlc"; 
reportViewer1.LocalReport.DataSources.Clear(); 
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("SwipeReport", dt)); 
reportViewer1.RefreshReport(); 

我不相信我设置了正确嵌入资源的报告我得到当它应该填补的ReportViewer窗口“的报告未指定”。我是否正确实施了这个?

回答

0

希望这有助于

 // create a new report from the created CrystalReport 
     GeneralSupportRpt myDataReport = new GeneralSupportRpt(); 

     // set the data source of the report 
     myDataReport.SetDataSource(dataTable); 

     // set the report source of the created “crystalReportViewer” 
     // component to the created report 

     ReportViewer.ReportSource = myDataReport;