2013-03-15 56 views
2

在我的ASP.Net网页项目中,我创建了一个新的Web页面,然后将一个脚本管理器控件拖到它上面,然后I使用向导创建了一个新的rdlc报告,并配置了该数据集(显示3个字段产品表:ProductName,quatityPerUnit,Price),它开始检索数据。rdlc report''数据源实例未提供数据源'错误

在接下来的步骤中,我插入了一个新的Reportviewer并将其绑定到先前创建的报告,然后再次验证数据是通过打开dataset1.xsd文件并单击预览数据来检索的。

,这是我的网页机身码:

<body> 
    <form id="form1" runat="server"> 
    <div> 

     <asp:ScriptManager ID="ScriptManager1" runat="server"> 
     </asp:ScriptManager> 
     <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"> 
      <LocalReport ReportPath="Reports\MyRdlcReport.rdlc"> 
       <DataSources> 
        <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="dsProducts" /> 
       </DataSources> 
      </LocalReport> 
     </rsweb:ReportViewer> 
     <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="WebApplication1.dsProductsTableAdapters.ProductsTableAdapter"> 

     </asp:ObjectDataSource>   
    </div> 
    </form> 
</body> 

但是当我运行该项目,我得到了一个错误:数据源实例尚未为数据源“dataSource1”提供,我试图在网上找到类似的案例,但成功找不到任何东西,请帮忙吗?

+0

是您的请求迁移报表? – ashveli 2017-02-16 05:06:00

回答

4

最后我找到了原因,这是一个非对应Tablix数据集名称属性。我必须将其从dataSet1重命名为dsProducts。

5

你必须意识到的最后一步是谁defining of datasource

链接:http://ruchitech.blogspot.fr/2012/07/how-to-create-rdlc-report-in-c.html

注:参见选择数据源

enter image description here

+0

已经为报告定义了数据源,并且报告已分配给报告查看器,我已经看到了您的链接,并且我认为所有的操作都按照其中所示完成了... – 2013-03-15 15:29:48

+0

可视化您的代码并检查此行存在:rdlc.DataSource = .... – 2013-03-15 15:30:35

+0

更新了问题。 – 2013-03-15 15:52:07

-1

的Visual Studio 13提供了一个很好的解决方案来处理一个SQL Server存储过程的参数:

的ReportViewer 步骤要使用的ReportViewer

  1. 使用创建网络表单的网页版创建一个Web报告在网页网站/添加新项

  2. 拖动的ReportViewer

  3. 选择满足e创建新报告
  4. 选择报告的数据源(确保在保存前重命名)
  5. 使用报告生成器在报告上放置字段。
  6. 保存报表然后重命名report1.rdlc的默认名称所需
  7. 移动报告和网页所需目录
  8. 转到网页的ReportViewer任务,并选择报表。
  9. 然后选择数据源(报表参数可以在数据源添加)

选择新的数据源或报告会给出错误:

的数据源实例尚未对提供数据源'

  1. 将出现一个新屏幕,其中显示各种数据源。通常情况下选择SQL数据

  2. 选择指定自定义SLQ语句然后点击Next

  3. 选择存储过程或选择SLQ语句来查询生成器。选择存储过程将允许用户为存储过程的参数选择控件。然后,向导将正确配置从而在网络代码且不需要任何输入VB代码如下面:

Protected Sub ReportViewer1_Load(sender As Object, e As EventArgs) Handles ReportViewer1.Load 
    Dim Parm As New ReportParameter("BillingReportParm1", Profile.TherapistNo) 
    ReportViewer1.LocalReport.SetParameters(Parm) 
    ReportViewer1.LocalReport.Refresh() 
End Sub 
  1. 完成的HTML代码的一个例子是如下所示:

<asp:Content ID="Content2" ContentPlaceHolderID="cpMC" Runat="Server"> 
 
\t <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="383px" Width="721px"> 
 
\t \t <LocalReport ReportPath="Reports\BillingPendingRpt.rdlc"> 
 
\t \t \t <DataSources> 
 
\t \t \t \t <rsweb:ReportDataSource DataSourceId="SqlDataPendRpt" Name="BillingPendingRptDataSet" /> 
 
\t \t \t </DataSources> 
 
\t \t </LocalReport> 
 
\t </rsweb:ReportViewer> 
 
\t <asp:SqlDataSource ID="SqlDataPendRpt" runat="server" ConnectionString="<%$ ConnectionStrings:MMBDataConnectionString %>" SelectCommand="sp_WorkHour_Rpt" SelectCommandType="StoredProcedure"> 
 
\t \t <SelectParameters> 
 
\t \t \t <asp:ProfileParameter Name="Therapist" PropertyName="TherapistNo" Type="String" /> 
 
\t \t </SelectParameters> 
 
\t </asp:SqlDataSource> 
 
</asp:Content>