我在VS 2012下使用我想在运行时分配数据源和报告名称的报告创建了一个.rdlc-Report

时间:2017-08-20 08:50:05

标签: c# rdlc dynamic-rdlc-generation

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

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();

0 个答案:

没有答案