DataSet dsa;
            dsa = getdataset(bomautoid);//获得dataset
            //判断一下是否记录为零,如果为零就退出程序
            if (dsa.Tables[0].Rows.Count < 1)
            {
                MessageBox.Show("记录为零,无法打印");
                return;
            }
            //绑定报表
            DataTable dt1 = dsa.Tables[1];
            MessageBox.Show(dt1.Rows.Count.ToString());
            ReportDataSource rds2 = new ReportDataSource("BOM数据集_从表", dt1);
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(rds2);
            reportViewer1.LocalReport.Refresh();
编译的时候可以通过,MessageBox.Show(dt1.Rows.Count.ToString());还一句还可以显示8条记录,但是最终报表是空白,不知道是什么原因了.

解决方案 »

  1.   

     ReportDataSource rds2 = new ReportDataSource("BOM数据集_从表", dt1); 
    你在这句话的时候设个断点看下dt1中有没有数据再就是你报表上和字段绑定好了没?
      

  2.   

    this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
                this.reportViewer1.LocalReport.ReportPath = @"rdlc\ctlTableDemo.rdlc";
      
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ctlsDemo_vSales", dt1));
                //
                this.reportViewer1.RefreshReport();你看看。。没测试过你的·