2014-10-07 19 views
0

這是代碼:重載決策失敗,因爲沒有可訪問的「新」是最具體的這些參數

If ComboBox1.Text = "Total profil for all time" Then 

     Dim TA As New CPDBTableAdapters.TotalProfilForAllTimeTableAdapter 
     Dim TmpDS As New CPDB 
     TA.Fill(TmpDS.TotalProfilForAllTime) 


     'obriši prošli DS 
     RV.LocalReport.DataSources.Clear() 

     'dodaj novi DS 
     Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", TmpDS.TotalProfilForAllTime) 
     RV.LocalReport.DataSources.Add(RDS) 
     RV.LocalReport.ReportEmbeddedResource = "change_password.report1.rdlc" 
     RV.RefreshReport() 


    End If 

問題是在這裏:

Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", 
    TmpDS.TotalProfilForAllTime) 

錯誤消息: 重載決策失敗,因爲沒有可訪問的'new'對於這些論點來說是最具體的。

+1

「TmpDS.TotalProfilForAllTime」的類型是什麼? – 2014-10-07 21:00:08

+0

TotalProfilForAllTime是tableadapter,TmpDs。 (Dim TmpDS As New CPDB) – 2014-10-07 21:06:22

回答

0

根據TmpDS.TotalProfilForAllTime的類型,鑄傳遞給構造函數的第二個參數:

Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, DataTable)) 

或:

Dim RDS As New Microsoft.Reporting.WinForms.ReportDataSource("", CType(TmpDS.TotalProfilForAllTime, IEnumerable)) 

VB不能清楚地挑最好的構造函數重載,所以你必須爲編譯器提供一些幫助。請參閱此鏈接以獲取可能的第二個參數類型。 http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportdatasource.reportdatasource(v=vs.100).aspx 這是VB代碼中的一個常見問題,因爲VB對解釋對象類型的要求不是很嚴格 - 它允許在允許使用一種對象類型代替另一種對象類型(特別是使用Option Strict Off)方面有更多的變化。

相關問題