Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I keep getting an error during the LocalReport.Render method call - InnerException = "A data source instance has not been supplied for the data source". The dataset and table supplied is valid as it works with the Reportviewer control. Is there something I am missing or is the sample code wrong?

ASP.NET
<asp:ScriptManager ID="sm" runat="server" />
  
  <rsweb:reportviewer id="rv_ipd"  runat="server" width="900px" font-names="Verdana"
     font-size="8pt" height="617px" interactivedeviceinfos="(Collection)" waitmessagefont-names="Verdana"  waitmessagefont-size="14pt">
    </rsweb:reportviewer>


C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
          //rv_ipd.ProcessingMode = ProcessingMode.Local;
           DataSet1 ds = new DataSet1(); //27-3-2014  DataSet1 is dataset.  DataSet1.xsd
           ReportDataSource datasourse = new ReportDataSource("DataSet1", ds.Tables[0]);
           rv_ipd.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
           rv_ipd.LocalReport.DataSources.Clear();
           rv_ipd.LocalReport.DataSources.Add(datasourse);

       }

   }
Posted

After removing ' rv_ipd.LocalReport.DataSources.Clear();'

Got this error --->

A data source instance has not been supplied for the data source 'DataSet1_tb_employee'.
 
Share this answer
 
provide table name with dataset in report data source...


C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
          //rv_ipd.ProcessingMode = ProcessingMode.Local;
           DataSet1 ds = new DataSet1(); //27-3-2014  DataSet1 is dataset.  DataSet1.xsd
           ReportDataSource datasourse = new ReportDataSource("DataSet1_tableName", ds.Tables[0]);
           rv_ipd.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
           rv_ipd.LocalReport.DataSources.Clear();
           rv_ipd.LocalReport.DataSources.Add(datasourse);

       }

   }
 
Share this answer
 
Thanks Its Working now


Final Code here

C#
string query = @"SELECT tb_employee.emp_id, tb_employee.emp_name, tb_emp_role.emp_role
                         FROM            tb_emp_role INNER JOIN
                         tb_employee ON tb_emp_role.emp_role_id = tb_employee.emp_role_id";
        ds=dl.fetchrecord(query);
        dl.ConnectionOpen();
        ReportViewer2.Reset();
        ReportDataSource rptsrc = new ReportDataSource("DataSet1_tbl_detail", ds.Tables[0]);
        ReportViewer2.LocalReport.DataSources.Add(rptsrc);
        ReportViewer2.LocalReport.ReportPath = Server.MapPath("report.rdlc");
        ReportViewer2.LocalReport.Refresh();
        ReportViewer2.Visible = true;
        dl.ConnectionClose();
 
Share this answer
 
Can you tell which line throws this error? i think you can try removing the line
' rv_ipd.LocalReport.DataSources.Clear();'
 
Share this answer
 

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