簡體   English   中英

重載解析失敗,因為對於這些參數,沒有可訪問的“新”是最具體的

[英]Overload resolution failed because no accessible 'new' is most specific for these arguments

這是代碼:

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)

錯誤消息:重載解析失敗,因為對於這些參數,沒有可訪問的“新”是最特定的。

根據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/zh-cn/library/microsoft.reporting.winforms.reportdatasource.reportdatasource(v=vs.100).aspx這是VB代碼中的常見問題,因為VB在解釋方面不是很嚴格對象類型-在允許使用一種對象類型代替另一種對象類型時(尤其是在Option Strict Off下),它允許更多的變化。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM