2010-02-12 79 views
1

我有Windows 7上的SQL Server 2008年。我試圖設計一個非常簡單的本地報告顯示在窗口上的報表查看器控件中的數據庫表中的大約10條記錄構成應用程序啓動表單當我運行應用程序的報告顯示,我可以看到報告標題文本,但它不顯示任何行(並在表中有行)。即使當我預覽報告DataTable時,行也在那裏。當我在Windows XP和SQL 2008上嘗試相同的操作時,會出現這些行。任何知道我可能會錯過的東西。在Windows 7上的SQL Server 2008空的本地報告

回答

0

數據綁定後,您必須刷新報告。在代碼末尾寫上這行:

ReportViewerControl.LocalReport.Refresh(); 

也許你的數據源名稱是錯誤的。您的數據源名稱必須是這樣的:

DataSetName_DataTableName

+0

我這樣做,我的報告仍然是空的。我可以看到Tablix,它是標題,但沒有顯示數據。我知道數據集返回的數據是因爲當我檢查ReportDataSource時,我可以看到預期的行數爲5。 – Marnee 2012-10-03 22:20:37

0

我有同樣的問題。我遵循msdn指南,但似乎有步驟丟失。以下是我做過的兩個例子。

用的BindingSource和TableAdapter的:

reportViewer1.LocalReport.ReportEmbeddedResource = _path; 
reportsBindingSource.DataSource = reportsTableAdapter.GetData(); 
ReportDataSource rds = new ReportDataSource("test", reportsBindingSource);    
reportViewer1.LocalReport.DataSources.Add(rds); 
reportViewer1.RefreshReport(); 
reportViewer1.LocalReport.Refresh(); 

隨着數據表

reportViewer1.LocalReport.ReportEmbeddedResource = _rptPath; 
reportViewer1.LocalReport.DataSources.Add(TOR2012()); 
//TOR2012 returns a ReportDataSource built from a data table 
reportViewer1.LocalReport.Refresh(); 
reportViewer1.RefreshReport();