2012-08-22 47 views
1

您好我正在使用C#2010和sql server compact edition 3.5來構建我的數據庫,並使用報表嚮導從我的數據庫生成報表,但不幸的是,在我發佈應用程序,即使插入了新記錄,我的報告查看器也不顯示任何內容。這裏是我的代碼簡單地顯示在報表查看器數據:發佈後不顯示任何數據

this.jadwalkuliahTableAdapter.Fill(this.Dataset.jadwalkuliah); 

     this.reportViewer1.RefreshReport(); 

注:報告觀衆從我的數據庫顯示的數據在調試過程。

+0

是否顯示報告標題,但沒有數據?你檢查過(sql trace)來查看數據庫是否被查詢? – Euric

+0

當然是。但是如何知道數據是否已被成功查詢?你會告訴我怎麼樣? –

+0

它是本地報告(rdlc)還是服務器報告(rdl)? – BizApps

回答

0

你缺少ReportDataSource:

this.reportViewer.LocalReport.DataSources.Clear(); 
DataTable dt = new DataTable(); 
dt = this.inputValuesTableAdapter.GetData();  

Microsoft.Reporting.WinForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WinForms.ReportDataSource(dt.TableName, dt); 

this.reportViewer.LocalReport.DataSources.Add(rprtDTSource); 
this.reportViewer.RefreshReport(); 

檢查下面這個網站:

how can I load datatable as ReportDataSource? SO

Building Reports from a DataSet using ReportViewer c-sharp corner

Creating Dataset Dynamically in c# and passing to Report Viewer.. asp.net forum

問候

+0

我不知道爲什麼當我使用sql server(而不是ce版本)時不會發生這種情況? –

+0

在你的數據源中沒有問題..請確保你的數據集/數據表有它的數據..http://stackoverflow.com/questions/8425551/cant-add-sql-compact-4-0-as-datasource- on-rdlc – BizApps

+0

我已經嘗試了上面的代碼,但也許你想在發佈應用程序後看到結果[link](http://db.tt/jStF4R5D) –