Click here to Skip to main content
15,991,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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();
}
Posted
Comments
Sandeep Mewara 18-Apr-13 14:02pm    
When you debug, do you see data in rds?
Member 8584763 18-Apr-13 15:16pm    
No, I don't.
Member 8584763 19-Apr-13 5:35am    
I solved it. the problem were in the index, but when I changed it to the table name it works fine.

Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900