none
A data source instance has not been supplied for the data source "DS_Build_DataTable1" RRS feed

  • Question

  • hi all,
     i am using visual stdio2005 C#. i want to load LocalReport control using reportviewer control,the report depend on a stored procedure
     but it gives the error
    • A data source instance has not been supplied for the data source "DS_Build_DataTable1".
    • This is my code. please help me and tell me what's wrong here

      SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["Build"].ToString());
                  string buildcode = Request.QueryString["buildcode"].ToString();
                  Microsoft.Reporting.WebForms.ReportParameter[] param = new Microsoft.Reporting.WebForms.ReportParameter[1];
                  param[0] = new Microsoft.Reporting.WebForms.ReportParameter("buildcode", buildcode);
                 
                  ReportViewer1.LocalReport.SetParameters(param);
                  ReportViewer1.ServerReport.Refresh();
                  SqlCommand comm = new SqlCommand("SurrPath_neibuild ", Con);
                  SqlParameter build_code = comm.Parameters.Add("@buildcode", SqlDbType.Int);
                  build_code.Direction = ParameterDirection.Input;
                  build_code.Value = buildcode; 
                  Con.Open(); 
                  SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
                  SqlDataSource1.SelectCommand = comm.CommandText;
                  Con.Close();
      i want to know what is the wrong.
    Tuesday, August 25, 2009 11:52 AM

All replies

  • Hi,
    Here are 2 things that I think needs to be addressed:

    1.  ReportViewer1.ServerReport.Refresh();  should have been ReportViewer1.LocalReport.Refresh(); as you have local report.

    2.  Secondly, I did not see the code that binds the viewer to the data source. 2 options mainly.

    a)  You can declaratively do the binding in the source view.  This is what the generated source looks like in the webform that does the data binding:

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"

     

    Font-Size="8pt" Height="400px" Width="400px">

     

    <LocalReport ReportPath="Report1.rdlc">

     

    <DataSources>

     

    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1"

     

    Name="DS_Build_DataTable1" />

     

    </DataSources>

     

    </LocalReport>

     

    </rsweb:ReportViewer>

     

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"

     

    SelectMethod="GetData"

     

    TypeName="Test.DataSetTableAdapters.DS_TableAdapter">

     

    </asp:ObjectDataSource>

    b)  Alternatively, you can set the data source in code using ReportViewer.LocalMode.DataSources.Add(reportDataSource);

    Thanks.

    Stella Chan
    Program Manager
    SQL Server Reporting Services
    -----------------

    This post is provided as-is with no support or warranty.

     

     




    • Proposed as answer by StellaC - MSFT Tuesday, August 25, 2009 11:25 PM
    Tuesday, August 25, 2009 11:24 PM
  • Hi,
       I did the code that binds the viewer to the data source, but i foget to write it in my question

    <

     

    div>

     

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"

     

    Height="481px" Width="927px">

     

    <LocalReport ReportPath="Reports\Build_data.rdlc">

     

    <DataSources>

     

    <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="DS_Build_DataTable1" />

     

    </DataSources>

     

    </LocalReport>

     

    </rsweb:ReportViewer>

     

     

    </div>

     

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BuildingDBConnectionString %>"

     

    SelectCommand="SurrPath_neibuild" SelectCommandType="StoredProcedure">

     

    <SelectParameters>

     

    <asp:Parameter Name="buildcode" Type="Int32" />

     

    </SelectParameters>

     

    </asp:SqlDataSource>

     

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"

     

    SelectMethod="GetData" TypeName="DS_BuildTableAdapters.SurrPath_neibuildTableAdapter">

     

    <SelectParameters>

     

    <asp:Parameter Name="buildcode" Type="Int32" />

     

    </SelectParameters>

     

    </asp:ObjectDataSource>

    i changed ReportViewer1.ServerReport.Refresh();   to    ReportViewer1.LocalReport.Refresh();
    and still have the same error

    Wednesday, August 26, 2009 7:59 AM