[Solved] ReportViewer Error: A data source instance has not been supplied for the data source DataSet1

akhter
 
on Oct 13, 2021 05:01 AM
1522 Views

Error: A data source instance has not been supplied for the data source DataSet1.

Below is my code,

I am trying to run two Dataset in one report in RDLC.

SqlCommand cmd1 = new SqlCommand("SP_Summary_Category", con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@StartDate", txtDateFrom.Text);
cmd1.Parameters.AddWithValue("@EndDate", txtDateTo.Text);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
ReportDataSource rds1 = new ReportDataSource();
rds1.Name = "DataSet1";
rds1.Value = ds1.Tables[0];
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.ReportPath = "Order.rdlc";
ReportViewer1.LocalReport.DataSources.Add(rds1);
//    ReportViewer1.LocalReport.Refresh();
ReportViewer1.Visible = true;
con.Open();
SqlCommand cmd = new SqlCommand("Sp_Ret_Prd_Bales", con);
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.AddWithValue("@EmpID", ddlEmployee.SelectedValue);
cmd.Parameters.AddWithValue("@StartDate", txtDateFrom.Text);
cmd.Parameters.AddWithValue("@EndDate", txtDateTo.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ReportDataSource rds = new ReportDataSource();
rds.Name = "DSord";             
rds.Value = ds.Tables[0];
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.ReportPath = "Order.rdlc";
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
ReportViewer1.Visible = true;

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download