2017-02-02 110 views
0

我正在嘗試添加一個reportviewer到我的WPF應用程序。我已經按照上This Site步驟,但現在我得到這個錯誤:報告'[Report Name]'的報告定義沒有被指定

An error occurred during local report processing. The report definition for report 'ConSegReport' has not been specified. Object reference not set to an instance of an object.

這裏是我的代碼:

private void Reportviewer_Load(object sender, EventArgs e) 
    { 
     if (!_IsReportViewerLoaded) 
     { 
      Microsoft.Reporting.WinForms.ReportDataSource reportData = new Microsoft.Reporting.WinForms.ReportDataSource(); 
      Consolidated_DBDataSet conSet = new Consolidated_DBDataSet(); 
      conSet.BeginInit(); 

      reportData.Name = "ConSegSet"; 
      reportData.Value = conSet.Cnsldtd_Performance_tbl; 
      this.reportViewer.LocalReport.DataSources.Add(reportData); 
      this.reportViewer.LocalReport.ReportEmbeddedResource = "FP Reporting Dashboard.ConSegReport.rdlc"; 

      conSet.EndInit(); 

      Consolidated_DBDataSetTableAdapters.Cnsldtd_Performance_tbl_CLONETableAdapter conAD = new Consolidated_DBDataSetTableAdapters.Cnsldtd_Performance_tbl_CLONETableAdapter(); 
      conAD.ClearBeforeFill = true; 
      conAD.Fill(conSet.Cnsldtd_Performance_tbl_CLONE); 

      reportViewer.RefreshReport(); 

      _IsReportViewerLoaded = true; 
     } 
    } 

我還設置.rdlc文件是否有更新的「複製「輸出目錄。

回答

0

我從來沒有嘗試引用嵌入式報表總是上傳到SSRS。

這裏是我的代碼,也許它會幫助:

IReportServerCredentials irsc = new CustomReportCredentials(rc.report_ssrs_username, 
    rc.report_ssrs_password, rc.report_ssrs_domain); 
ReportViewer1.ServerReport.ReportServerCredentials = irsc; 
ReportViewer1.ServerReport.ReportPath = rc.report_ssrs_path; 
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(rc.report_ssrs_url); 

SqlConnectionStringBuilder conString = new Database().conBuilder; 
List<ReportParameter> parameters = new List<ReportParameter>(); 
parameters.Add(new ReportParameter("ConString", conString.ConnectionString)); 
ReportViewer1.ServerReport.SetParameters(parameters); 
DataSourceCredentials dsc = new DataSourceCredentials(); 
dsc.Name = ReportViewer1.ServerReport.GetDataSources()[0].Name; 
dsc.UserId = conString.UserID; 
dsc.Password = conString.Password; 
ReportViewer1.ServerReport.SetDataSourceCredentials(new DataSourceCredentials[] { 
    dsc }); 

ReportViewer1.ShowCredentialPrompts = false; 
ReportViewer1.ServerReport.Refresh(); 

讓我知道,如果你有什麼我這裏有任何問題。我們有一張表格,它定義了我們所有的報表並查詢動態呈現報表查看器控件。

就像旁註一樣,我會爲RDLC文件使用下劃線命名約定。如果沒有正確解釋,那可能會導致代碼錯誤。另外嘗試引用它將會有一個完整的路徑來驗證這是不是相對路徑問題,如果它試圖從調試目錄或版本目錄引用該文件。