簡體   English   中英

重載解析失敗,因為沒有可訪問的“參數”接受此數量的 arguments

[英]Overload resolution failed because no accessible 'Parameters' accepts this number of arguments

我已將 VB.net 應用程序從 2.0 升級到 4.6。

我在這段代碼中遇到錯誤

System.MissingMemberException:重載解析失敗,因為沒有可訪問的“參數”接受此數量的 arguments。

可能是什么問題?

Private Function MyFunction123(ByRef oXMLConfigData As XmlNodeList, ByRef oCmdCommandCol As ArrayList, ByVal iCmdCount As Integer, ByRef oReturnDataset As ReturnValues) As Boolean

    Dim iCount As Integer
    Dim iRetVal As Integer
    Dim oCNode As XmlNode       
    Dim retVal As Boolean = False

    iRetVal = oCmdCommandCol(iCmdCount).Parameters(oCNode.ChildNodes(iCount).Attributes("SPParameter").Value).Value
    oCNode.ChildNodes(iCount).InnerText = iRetVal
    oReturnDataset.ReturnValues.AddReturnValuesRow(oCNode.Attributes("Name").Value, oCNode.ChildNodes(iCount).Attributes("Name").Value, oCNode.ChildNodes(iCount).InnerText)
    retVal = True
End Function

Function 被稱為

If Not MyFunction123(oXMLConfigSteps, oCmdCollection, iCountCmd, oReturnDataset) Then
    'Statements
End If

Where is the MyFunction123 method called, is it inside another function and outside the current class where it is declared, Since your function "MyFunction123" is Private, and if you are calling it outside the class you have to change access modifier or protected or public . 如果調用在另一個 function 內,也將 EXIT 更改為“Exit Function”。

我知道了。

Arraylist “oCmdCommandCol” 填充了多個 SqlCommand 對象,因此需要顯式類型轉換。 我更改了如下代碼並且它起作用了。 希望它會幫助有類似情況的人。

Private Function MyFunction123(ByRef oXMLConfigData As XmlNodeList, ByRef oCmdCommandCol As ArrayList, ByVal iCmdCount As Integer, ByRef oReturnDataset As ReturnValues) As Boolean

    Dim iCount As Integer
    Dim iRetVal As Integer
    Dim oCNode As XmlNode       
    Dim retVal As Boolean = False


    Dim cmd As SqlCommand
    cmd = New SqlCommand()
    cmd = CType(oCmdCommandCol(iCmdCount), SqlCommand)
    iRetVal =  cmd.Parameters(oCNode.ChildNodes(iCount).Attributes("SPParameter").Value).Value


    oCNode.ChildNodes(iCount).InnerText = iRetVal
    oReturnDataset.ReturnValues.AddReturnValuesRow(oCNode.Attributes("Name").Value, 
    oCNode.ChildNodes(iCount).Attributes("Name").Value, oCNode.ChildNodes(iCount).InnerText)
    retVal = True
End Function

暫無
暫無

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

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