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(); }
rds
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)