標籤:
轉自:http://www.cnblogs.com/ljx2012/p/4093474.html
有一群的朋友在用VS2012做資料報表時,老是提示
本地報表處理期間出錯。
尚未指定報表“Report1”的報表定義
未將對象引用設定到對象的執行個體。
我看了一下,步驟沒錯,我用VS2010做了一下,一切OK,沒問題,但用VS2013做時,
就提示這錯誤
後仔細看了一下設計產生的源碼,嘿,還真有區別,在VS2012與VS2013中,
ReportViewer產生的程式碼在引用報表資料時,使用的是ReportEmbeddedResource屬性
<LocalReport ReportEmbeddedResource="WebApplication1.Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
在VS2010的版本中使用的是ReportPath
<LocalReport ReportPath="Report1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
而ReportPath與ReportEmbeddedResource的區別是:
ReportPath是擷取或設定本地報表的本地檔案系統路徑,
設定 ReportPath 屬性將導致 ReportViewer 控制項從檔案系統自動載入所需的任何子報表。
設定此屬性將導致ReportEmbeddedResource 屬性的值被忽略
ReportEmbeddedResource是嵌入報表資源是已經作為資源儲存在調用程式集中的報表定義。
因為要手動修改使用ReportPath,就能解決這問題
本人在vs2008 網站ReportEmbeddedResource改為ReportPath="Report1.rdlc" 也可以了
(轉)在VS2012後的版本中做資料報表時,提示尚未指定報表“Report1”的報表定義