2011-12-14 439 views
3

私はrdlcレポートを作成しました。私は自分のフォームにreportViewerを持っています。 レポートを読み込もうとすると、「レポート 'xxxx.rdlc'のレポート定義が指定されていません」。私はこれを理解できません。 私はレポートに必要なデータでデータテーブルを持っています。 私はこのdataTableを取り、それをデータベース "FinalReport"にロードします。 (私がこれをやっているのは、rdlcに何らかのデータソースが必要なためです。 私は自分のレポート(table1)の中にテーブルを持っています。 これは、(レポートビューアが配置されている私の形、内部の)私のコードです:RDLCレポートで「xxxx.rdlc 'レポートのレポート定義が指定されていません」

this.finalDataReportTableAdapter.Fill(this.nehasitDataSet.FinalDataReport); 
localReport.ReportEmbeddedResource = @"Resources\VisibleAssets.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(@"Resources\VisibleAssets.rdlc")) 
{ 
    localReport.LoadReportDefinition(rdlcSR); 

    localReport.Refresh(); 
} 

this.reportViewer.RefreshReport(); 

私もレポートにのdataTableとレポートビューアーにレポートを接続します。 私は本当に問題を見ることができません、私はそれをGoogleで検索しました。

すべてのヘルプは高く評価されます。

+1

レポートのパスに 'reportViewer.LocalReport.ReportPath'プロパティを設定しようとしましたか? – jadarnel27

+1

こんにちは。私は持っているので、私はする必要はありません:localReport.ReportEmbeddedResource = @ "リソース\ VisibleAssets.rdlc"; –

答えて

0

ここで、localReportをreportViewerに関連付けますか?代わりに:

using (StreamReader rdlcSR = new StreamReader(@"Resources\VisibleAssets.rdlc")) 
    { 
     localReport.LoadReportDefinition(rdlcSR); 

     localReport.Refresh(); 
    } 

私が使用:

using (StreamReader rdlcSR = new StreamReader(@"Resources\VisibleAssets.rdlc")) 
    { 
     reportViewer1.LocalReport.LoadReportDefinition(rdlcSR); 

     reportViewer1.LocalReport.Refresh(); 
    } 

をそして、それは私のために働いているようです。

1

同じエラーが発生しましたが、別の方法でレポートを読み込んでいます。私はMSDNの指示に従った。代わりにReportEmbeddedResource Iを参照する場合を除き、ReportPathを使用してください。その変更を行うと、レポートが読み込まれます。私のXAMLはまた

<Page x:Class="MyProject.Views.ReportViewer" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xm![enter image description here][2]lns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300" 
    Title="ReportViewer"> 

    <Grid> 
     <WindowsFormsHost> 
      <rv:ReportViewer x:Name="_reportViewer"/> 
     </WindowsFormsHost> 
    </Grid> 
</Page> 

された状態で

public partial class ReportViewer : Page 
{ 
    private bool _isReportViewerLoaded; 

    public ReportViewer() 
    { 
     InitializeComponent(); 
     _reportViewer.Load += _reportViewer_Load; 
    } 

    void _reportViewer_Load(object sender, EventArgs e) 
    { 
     if (!_isReportViewerLoaded) 
     { 
      Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource(); 
      BossbergDataset dataset = DataAccessConstants.myDataset; 

      dataset.BeginInit(); 

      reportDataSource1.Name = "DataSet1"; //Name of the report dataset in our .RDLC file 
      reportDataSource1.Value = dataset.Table1; 
      this._reportViewer.LocalReport.DataSources.Add(reportDataSource1); 
     //My testReport.Rdlc has the [Copy to Output Directory] set to [Copy Always] 
      this._reportViewer.LocalReport.ReportPath = @"Reports/TestReport.rdlc"; 

      dataset.EndInit(); 

      DataAccessConstants.Table1Adapter.Fill(dataset.Table1); 

      _reportViewer.RefreshReport(); 

      _isReportViewerLoaded = true; 
     } 
    } 
} 

  • あなたは出力ディレクトリにレポートファイルをコピーしていることを確認してください。 ../../Myreport.rdlcのような構文を使用している場合は、出力ディレクトリにコピーしていない可能性があります。 Output Directory requirements

  • ReportViewer dllの正しいバージョンを参照していることを確認してください。 References> Add Reference ...> Assemblies> Extensionsに行き、レポートビューアdllが古いバージョンであることがわかりました。私は明示的に最新のを見つけるには

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\ReportViewer\Microsoft.ReportViewer.WinForms.dll

    に移動する必要がありました。それが間違っている場合は、

    のようなエラーが表示されます。レポート定義は無効です。詳細:レポート定義に無効なターゲット名前空間 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'があり、アップグレードできません。

1

IISに同じアプリケーションを公開するときにのみ発生する可能性がある。この問題は、時には問題を引き起こして、いくつかの理由があります。レポートファイル(*。RDLC)は、関連する場所に存在しており、問題はまだ続く、あなたはそれを修正するために、次の方法を試すことができますされています

LocalReport.ReportEmbeddedResource Property on MSDN
「から...埋め込みレポートリソースがあり、レポート定義であります呼び出し元アセンブリにリソースとして格納されています。 ReportPathプロパティが設定されている場合、ReportEmbeddedResourceプロパティは無視されます。またLoadReportDefinitionを搭載した報告書は無視され、「

変更:

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

に:その後、

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

からEmbedded ResourceBuild Actionプロパティを変更しますYourReportName.rdlcファイルのプロパティ。これは正確にあなたがそのRDLCデータソースのいくつかの並べ替えを必要とするため:)これは、レポートビューアでトリッキーな問題であり、それを解決するために、私は結合する方法を書いた言ったような...


0

を役に立てば幸いDATATABLEから直接レポート:

private void GenerateReportDirect(ReportViewer reportViewer, string datasource, DataTable dt, string reportpath) 
{ 
    reportViewer.LocalReport.ReportPath = reportpath; 
    ReportDataSource repds = new ReportDataSource(datasource, dt); 
    reportViewer.LocalReport.DataSources.Clear(); 
    reportViewer.LocalReport.DataSources.Add(repds); 
    reportViewer.LocalReport.Refresh(); 
} 

とあなただけの名前、データセットテーブルアダプタの文字列を入れて指定する必要があり、このメソッドを実装するために私たちのレポートは、データテーブルからバインドするデータがかかります(私たちがカンニングします私たちのレポートビューア:))

private void BindReport(DataTable dt) 
    { 
      string reportPath = Server.MapPath("StudentBus.rdlc"); 
      GenerateReportDirect(ReportViewer1, "StudentDataSet_usp_RPT_StudentBus", dt, reportPath); 
    } 

私はこれが役に立ちそうです:)。

0

私の報告書でこの同じ問題が発生しました。それはローカルで埋め込まれたレポートでした。

  1. 私はReportEmbeddedResourceプロパティセットを持っていませんでした。
  2. ReportEmbeddedResource propertyに設定した場合、レポート名にはmyApp.reports.rptMyJobStatus.rdlcではなく、myApp.reports.rptMyJobstatus.rdlcという大文字と小文字の区別があったため、エラーが発生しました。

したがって、これらの条件の両方をチェックする必要があります。

関連する問題