RDLC Report: A data source instance has not been supplied for the data source

Last Reply on Jul 08, 2015 01:54 AM By Mudassar

Posted on Jul 08, 2015 01:44 AM
  • A data source instance has not been supplied for the data source 'bramandamDataSet_Expenzsection'.

 

<asp:TextBox ID="txtID" runat="server"></asp:TextBox>
    <asp:Button ID="btn1" runat="server" Text="Generate report"
        onclick="btn1_Click" />
        <br />
        <br />
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
            Font-Size="8pt" Height="318px" Width="1094px">
            <localreport reportpath="Report2.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1"  Name="bramandamDataSet_Expenzsection" />
                </DataSources>
            </localreport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"  InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"    SelectMethod="GetData"   TypeName="bramandamDataSetTableAdapters.ExpenzsectionTableAdapter">
            <InsertParameters>
                <asp:Parameter Name="sectionname" Type="String" />
                <asp:Parameter Name="ExpensesName" Type="String" />
                <asp:Parameter Name="Date" Type="String" />
                <asp:Parameter Name="BillNo" Type="String" />
                <asp:Parameter Name="BillAmount" Type="Double" />
            </InsertParameters>
        </asp:ObjectDataSource>

 

 protected void btn1_Click(object sender, EventArgs e)
    {
        
        ReportViewer1.Visible = true;
      
         string id = txtID.Text;
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report2.rdlc");
            DataSet ds = new DataSet();
            ds = GetData(id);
            if (ds.Tables[0].Rows.Count > 0)
            {
                ReportDataSource rds = new ReportDataSource("bramandamDataSet", ds.Tables[0]);
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(rds);
                
            }
            

    }

 

 private DataSet GetData(string id)
        {
          
           SqlConnection con = new SqlConnection("Data Source=FLOOR1\\SQLEXPRESS;Initial Catalog=bramandam;Integrated Security=True");
            con.Open();
            SqlCommand cmd = new SqlCommand();
            string qry ="select sectionname,expensesname,date,billno,billamount from expenzsection where date='" + id + "'order by sectionname";
            
            SqlDataAdapter da = new SqlDataAdapter();
            cmd = new SqlCommand(qry, con);
            da = new SqlDataAdapter(cmd);
            da.Fill(ds);
            return ds;
        }

 

 

Posted on Jul 08, 2015 01:54 AM

You are setting DataSource from code as well as from ASPX.

Use anyone

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html