重载解析失败,因为没有可访问的“参数"接受此数量的参数 [英] Overload resolution failed because no accessible 'Parameters' accepts this number of arguments

查看:1556
本文介绍了重载解析失败,因为没有可访问的“参数"接受此数量的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将VB.net应用程序从2.0升级到4.6.

I have upgraded a VB.net application from 2.0 to 4.6.

我在代码段中遇到了错误

I am getting below error in the piece of code

System.MissingMemberException:重载解析失败,因为没有可访问的"Parameters"接受此数量的参数.

System.MissingMemberException: Overload resolution failed because no accessible 'Parameters' accepts this number of 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

函数称为

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

推荐答案

我明白了.

Arraylist"oCmdCommandCol"被多个SqlCommand对象填充,因此需要显式类型转换.我更改了代码,如下所示,它可以正常工作.希望它能帮助处于类似情况的人.

Arraylist "oCmdCommandCol" was filled with multiple SqlCommand objects hence and explicit type cast is required. I changed the code as below and it worked. Hope it will help someone in similar situation.

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

'Changed code -Start-

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

'Changed code -End-

    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

这篇关于重载解析失败,因为没有可访问的“参数"接受此数量的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆