问题
I'm trying out SSRS for the first time with an ASP.Net web form.
I created a local RDLC report and used a ReportViewer in the "Default" web form. Under the smart tag I chose "Choose Report" and selected the RDLC report.
When I pressed f5 to run the report the following error was displayed even though I did choose the report from the smart tag.
"The report definition for report 'xxx' has not been specified."
Please let me know why this is not working as expected.
Thanks.
Coding for the report:
<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1><%: Title %>.</h1>
<h2>Modify this template to jump-start your ASP.NET application.</h2>
</hgroup>
<p>
To learn more about ASP.NET, visit <a href="http://asp.net" title="ASP.NET Website">http://asp.net</a>.
The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET.
If you have any questions about ASP.NET visit <a href="http://forums.asp.net/18.aspx" title="ASP.NET Forum">our forums</a>.
</p>
</div>
</section>
</asp:Content>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="739px">
<LocalReport ReportEmbeddedResource="WebApplicationFirstReports.Web Products.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="DataSetWebTableAdapters.DataTable1TableAdapter"></asp:ObjectDataSource>
</asp:Content>
回答1:
Okay, so it looks like you are missing your ReportPath in your local report. Here is a code example straight from my working project.
<body class="center">
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Label ID="lblCheckDate" runat="server" Visible="False"></asp:Label>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="800px" Width="620px" CssClass="center" BackColor="White" ShowBackButton="False" ShowPageNavigationControls="False">
<LocalReport ReportPath="Paystub.rdlc" ReportEmbeddedResource="PayrollApplication.Paystub.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:pay %>"
SelectCommand="SELECT * FROM [ViewPaychecks] WHERE ([CHKDATE] = @CHKDATE)">
<SelectParameters>
<asp:ControlParameter ControlID="lblCheckDate" Name="CHKDATE" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
Let me know if this helped! I used an SqlDataSource but this should work with the ObjectDataSource as well.
回答2:
This happens when you deploy in live site and report's .rdlc
file is not yet published in the site, so here is the solution which worked form me:
- Right click on your Report's '.rdlc' file , select properties then set the property Build Action of the rdlc to Content.
Screen Shot:
Reference:
This and This
Hope that helps.
回答3:
I had a the same error message and resolved it by adding the following two (2) lines at the end of the report definition:
ReportViewer1.LocalReport.Refresh()
ReportViewer1.RefreshReport()
来源:https://stackoverflow.com/questions/18986829/the-report-definition-for-report-xxx-has-not-been-specified