locked
passing dataset to report viewer RRS feed

  • Question

  • User-470983441 posted

    hello guys,

    I'm passing dataset to report viewer, but there're no data in the report?

    This is the code I found in your fourm.

    SqlConnection con = new SqlConnection();

    protected void Page_Load(object sender, EventArgs e)
    {
    con.ConnectionString = connection.x;
    con.Open();

    if (!Page.IsPostBack)
    {
    runRptViewer();
    }
    }

    private DataTable getData()
    {
    DataSet1 dss = new DataSet1();
    string sql = "";
    sql = "SELECT product_id, product_name from product";
    SqlDataAdapter da = new SqlDataAdapter(sql, con);
    da.Fill(dss);
    DataTable dt = dss.Tables[0];
    return dt;
    }

    private void runRptViewer()
    {
    this.ReportViewer1.Reset();
    this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report1.rdlc");
    ReportDataSource rds = new ReportDataSource("DataSet1", getData());
    this.ReportViewer1.LocalReport.DataSources.Clear();
    this.ReportViewer1.LocalReport.DataSources.Add(rds);
    this.ReportViewer1.DataBind();
    this.ReportViewer1.LocalReport.Refresh();
    }

    Thursday, April 18, 2013 9:28 AM

All replies

  • Thursday, April 18, 2013 9:45 AM
  • User-470983441 posted

    it's different from the code I put. I used sql query and the website you put sql paramenter?

    I don't know who it's going to help.

    Thursday, April 18, 2013 9:56 AM
  • User589263704 posted

    I have make a report with one procedure, loading a dataset, the report is working fine with this code:

    ReportParameter[] p = new ReportParameter[1]; p[0] = new ReportParameter("cnpj",cnpj); this.reportViewer1.LocalReport.SetParameters(p); this.cargaPJTableAdapter.Fill(this.ifdcontroladoria3DataSet1.cargaPJ,cnpj); this.reportViewer1.RefreshReport(); 

    my question is, I have add a second dataset based on another procedure named cargaEND. How do I call the second dataset and pass the parameter to the second procedure? I have tried this with no sucess:

    this.cargaPJTableAdapter.Fill(this.ifdcontroladoria3DataSet1.cargaEND,id);
    Sunday, April 21, 2013 1:02 PM