0

我的项目有很多报告,我只有一个报告查看器,并且想在此查看器中打开所有报告,因为此查看器数据源是在运行时分配的,并且报告名称也

DataSet ds = new DataSet();

DataTable dt = new DataTable();              

using (SqlCommand cmd = new SqlCommand("R_PURCHASE_ORDER_DETAIL", parent.v_connection))
{
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(new SqlParameter("START_CODE", SqlDbType.VarChar)).Value = "0000000000";
    cmd.Parameters.Add(new SqlParameter("END_CODE", SqlDbType.VarChar)).Value = "9999999999";
    cmd.ExecuteNonQuery();
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    da.Fill(ds);
}
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.ReportPath = @"E:\BusinessBook\BusinessBook\BusinessBook\ZReports\Purchase\r_purchase_order_detail.rdlc";

ReportDataSource datasource = new ReportDataSource("R_PURCHASE_ORDER_DETAIL", ds.Tables[0]);

this.reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(datasource);
reportViewer1.LocalReport.Refresh();
reportViewer1.RefreshReport();
4

0 回答 0