2010-11-23 20 views
2

ssrsのサブレポート部分を初めて使用しました。標準のテーブルと行列とタブリックスのコントロールでうまくいくいくつかのコードをセットアップしましたが、ロードするサブレポートを取得できませんでした。私は同じことを続けていますSSRS Subreport VS2010サブレポートのデータ取得に失敗しました

Visual Studio 2010で作業するサブレポートのサンプルコードはありますか?

エラーメッセージ "サブレポートのデータ検索に失敗しました"。

私のコードは、サブレポートにデータを渡そうとするためにさまざまなシナリオを試しましたが、このように見えます。ジンチェンマイクロソフトから

private void LoadReport(string reportName) 
    { 
     reportViewer1.Clear(); 
     //http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/b039e765-3cc8-43ec-ae67-14b9656bc981 
     reportViewer1.Reset(); 
     // Set Processing Mode 
     reportViewer1.ProcessingMode = ProcessingMode.Local; 

     // Set RDL file 
     reportViewer1.LocalReport.ReportPath = reportName+".rdlc"; 

    } 

    public void LoadReport(IEnumerable products, string reportName, string dataSourceName) 
    { 
     LoadReport(reportName); 

     ReportParameter myParam = new ReportParameter("ReportParameter1", st.ToString() + " TO " + et.ToString()); 
      reportViewer1.LocalReport.SetParameters(new ReportParameter[] { myParam }); 

     reportViewer1.LocalReport.DataSources.Add(
      new ReportDataSource(dataSourceName, products)); 


     reportViewer1.LocalReport.DataSources.Add(
      new ReportDataSource(dataSourceName+"Subreport", products)); 

     // Process and render the report 
     reportViewer1.RefreshReport(); 
    } 

答えて

3

、ModeratorUsersメダルMSDNフォーラム http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/5d2aed0b-ea69-4cbb-b3c4-b306a48fbc30

上 答えは、ありがとうございました!!!

私はこのコードを持っていたが、私は、イベントが、私は

reportViewer1.LocalReport.SubreportProcessingこの行を移動しGUIイベントプロパティウィンドウの事

とあなたの例次を経由して追加フォームデザイナで追加されました+ =新しいMicrosoft.Reporting.WinForms.SubreportProcessingEventHandler(this.reportViewer1_suberport1);

あなたの例で行ったように、form.designer.csからリフレッシュレポートの後まで、今は仕事しています!

はあなたに素晴らしい感謝をありがとう、私は別の場所にイベントハンドラを移動すると、この特定のエラーのために助けたことを見つけることができませんでした

reportViewer1.RefreshReport(); reportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WinForms.SubreportProcessingEventHandler(this.reportViewer1_suberport1);

private void reportViewer1_suberport1(object sender, SubreportProcessingEventArgs e) 
    { 

     ReportDataSource r=reportViewer1.LocalReport.DataSources[0]; 
     e.DataSources.Add(r); 

    } 

1

をやれやれ。このエラーでは、修正された内容は、サブレポートがエラーなしでスタンバイで実行できることを確認する必要があります。次に、それをメインレポートに結びつけます。私の場合、私のレポートではIDEで別のデータセットを使用していました。

関連する問題