2015-02-09 92 views
0

我已經在SSRS中創建了報告,它在工作正常,在需要顯示記錄的構建器上工作。從C#窗口應用程序調用SSRS報告

現在我想從窗口應用程序調用報告作爲LOCALREPORT。我已通過參數要求報告。但它顯示錯誤A data source instance has not been supplied for the data source Dataset1

的代碼如下:

ReportV.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local; 
LocalReport localreport = ReportV.LocalReport; 
localreport.ReportPath = "Result.rdl"; 
ReportParameter _para_sid = new ReportParameter(); 
_para_sid.Name = "s"; 
_para_sid.Values.Add("313"); 
ReportParameter _para_courseid = new ReportParameter(); 
_para_courseid.Name = "Cid"; 
_para_courseid.Values.Add("BSB50207"); 
ReportParameter[] _rp = new ReportParameter[2]; 
_rp[1] = _para_sid; 
_rp[0] = _para_courseid; 
localreport.SetParameters(_rp); 
ReportV.RefreshReport(); 

回答

1

你是在本地處理,但您的報告是「Result.rdl」。 RDL文件通常運行在SSRS服務器的上下文中。在ReportViewer控件中本地運行的報告通常具有RDLC擴展,並使用其設計器在Visual Studio中創建。

有沒有理由不使用ReportViewer控件上的遠程處理模式?如果您試圖從組合中刪除SSRS服務器,我認爲您必須將RDL報告轉換爲RDLC。他們非常相似,但不完全一樣。這裏有一篇文章討論了相反的翻譯,但可能會發光 - https://msdn.microsoft.com/en-us/library/ms252109.aspx

如果您使用Visual Studio中的設計器創建一個簡單的RDLC報表,然後將其拖到表單上,您將看到Visual Studio創建了一個DataSet,BindingSource和TableAdapter來讀取報表的數據。我認爲你需要做類似的事情來閱讀你的數據。

當然,如果這是一個簡單的報告 - 您可以在VS報表設計器中重新創建。