尚未为数据源“DS_Build_DataTable1”提供数据源实例。 [英] A data source instance has not been supplied for the data source "DS_Build_DataTable1"

查看:66
本文介绍了尚未为数据源“DS_Build_DataTable1”提供数据源实例。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在使用visual stdio2005 C#。 i 想要使用 reportviewer控件加载 LocalReport控件,报告依赖于存储过程
但它给出错误


  • 尚未为数据源提供数据源实例"DS_Build_DataTable1"。

  • 这是我的代码。请帮帮我,告诉我这里有什么问题。

    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 string build = 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 SqlCo mmand(" 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();
        我想知道出了什么问题。

      推荐答案

      这是我认为需要解决的两件事:

      1。 ReportViewer1.ServerReport.Refresh(); 应该是ReportViewer1.LocalReport.Refresh();因为你有本地报道。

      2。其次,我没有看到将查看器绑定到数据源的代码。主要有2个选项。

      a)您可以在源视图中声明性地进行绑定。这是生成的源在执行数据绑定的webform中的样子:

      < < span style ="font-size:x-small; color:#a31515"> rsweb ReportViewer ID =" ReportViewer1" runat =" server" < /跨度> 字体名称 =" Verdana"

      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" 高度 =" 400px" 宽度 =" 400px">

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

      < LocalReport ReportPath =" Report1.rdlc">

      <LocalReport ReportPath="Report1.rdlc">

      < < span sty le ="font-size:x-small; color:#a31515"> DataSources >

      <DataSources>

      < < span style ="font-size:x-small; color:#a31515"> rsweb ReportDataSource DataSourceId =" ObjectDataSource1"

      <rsweb:ReportDataSource DataSourceId="ObjectDataSource1"

       

      名称 =" DS_Build_DataTable1" />

      Name="DS_Build_DataTable1" />

      < / DataSources >

      </DataSources>

      < / < span style ="font-size:x-small; color:#a31515"> LocalReport >

      </LocalReport>

      < / rsweb ReportViewer >

      </rsweb:ReportViewer>

      < asp ObjectDataSource ID < span style ="font-size:x-small; color:#0000ff"> =" ObjectDataSource1" runat =" server"

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

       

      SelectMethod =" GetData"

      SelectMethod="GetData"

       

      TypeName =" Test.DataSetTableAdapters.DS_TableAdapter">

      TypeName="Test.DataSetTableAdapters.DS_TableAdapter">

      < / < span style ="font-size:x-small; color:#a31515"> asp ObjectDataSource >

      b)或者,您可以使用ReportViewer.LocalMode.DataSources.Add(reportDataSource)在代码中设置数据源;

      谢谢。

      Stella Chan
      项目经理
      SQL Server Reporting Services
      -----------------

      本帖子按原样提供,不提供任何支持或担保

      </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.




      这篇关于尚未为数据源“DS_Build_DataTable1”提供数据源实例。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆