繁体   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