Home > DeveloperSection > Forums > passing dataset to report viewer
Ahmed Algosaibi
Ahmed Algosaibi

Total Post:1

Points:7
Posted on    April-17-2013 11:51 AM

 C# C# 
Ratings:


 1 Reply(s)
 2025  View(s)
Rate this:
Hello guys,
I've windows app that uses report viewer, but the problem that I don't get result back?

This is my code.

private void Form3_Load(object sender, EventArgs e)
        {
            con.ConnectionString = connection.x;

            runRptViewer();
        }

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

        return dt;
    }

    private void runRptViewer()
    {      
            reportViewer1.LocalReport.DataSources.Clear(); //clear report
            reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc"; // bind reportviewer with .rdlc
            Microsoft.Reporting.WinForms.ReportDataSource dataset = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", getData()); // set the datasource
            reportViewer1.LocalReport.DataSources.Add(dataset);
            reportViewer1.LocalReport.Refresh();
            reportViewer1.RefreshReport();
    }


Chris Anderson
Chris Anderson

Total Post:65

Points:455
Posted on    May-02-2013 8:15 AM


Don't want to miss updates? Please click the below button!

Follow MindStick