Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
921 views
in Technique[技术] by (71.8m points)

c# - I'm getting "The report definition for report 'xxxx.rdlc' has not been specified" in my RDLC report

I've created an rdlc report. I have a reportViewer on my form. When I try to load the report I get : "The report definition for report 'xxxx.rdlc' has not been specified". I can't figure this out. I have a datatable with the data I need for the report. I take this dataTable and I load it back to my database, to a table called "FinalReport". (The reason i'm doing this, is because that rdlc requires some sort of a dataSource.) I have a table inside my report (table1). This is my code (inside my form, where the report viewer is located):

this.finalDataReportTableAdapter.Fill(this.nehasitDataSet.FinalDataReport);
localReport.ReportEmbeddedResource = @"ResourcesVisibleAssets.rdlc";
//I'm not so sure about the following line, but it's the only line that prevented me from getting an error ("no reportdefinition defined"
using (StreamReader rdlcSR = new StreamReader(@"ResourcesVisibleAssets.rdlc"))
{
    localReport.LoadReportDefinition(rdlcSR);

    localReport.Refresh();
}

this.reportViewer.RefreshReport();

I also connected the report to the dataTable and the reportViewer to the report. I really can't see the problem, and I searched Google for it.

Any help will be highly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are some reasons causing this problem and sometimes the problem might occur only when publishing the same application to IIS. If the report file (*.rdlc) is existed in the related location and the problem still continues, you can try the following methods in order to fix it:

from LocalReport.ReportEmbeddedResource Property on MSDN
“… An embedded report resource is a report definition that has been stored as a resource in the calling assembly. If the ReportPath property has been set, the ReportEmbeddedResource property is ignored. It also causes the report loaded with LoadReportDefinition to be ignored.”

Change:

reportViewer.LocalReport.ReportPath = Server.MapPath("~/Reporting/YourReportName.rdlc");

to:

rw.LocalReport.ReportEmbeddedResource = "YourFullNamespace.Reporting.YourReportName.rdlc";

And then change Build Action property to Embedded Resource from the properties of YourReportName.rdlc file. Hope this helps...



与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...