无法在与VBA中请求的名称或序号对应的集合中找到item [英] item cannot be found in the collection corresponding to the requested name or ordinal in VBA

查看:99
本文介绍了无法在与VBA中请求的名称或序号对应的集合中找到item的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,

我正在尝试在vba中调用oracle存储过程。但是当我尝试捕获输出参数时,我的记录集中出现了错误:"无法在与所请求的名称或序号对应的集合中找到项目"。谁能帮我?怎么了?
以下是我的代码。

I'm trying call an oracle stored procedure in vba. But when I tried catch the output parameters I've got the error in my recordset: "item cannot be found in the collection corresponding to the requested name or ordinal". Can Anyone help me? What is wrong? Below is my code.

谢谢.. !!

   On Error Resume Next

    Dim cn As New ADODB.Connection

    Dim rs As New ADODB.Recordset

    Dim MyCommand As New ADODB.Command



    Err.Number = 0

    cn.CursorLocation = adUseClient

    cn.ConnectionString = ConnectionString.N3

    'Abre Conexao

    cn.Open



   如果Err.Number = 0则为


       设置MyCommand =新ADODB.Command



       使用MyCommand

           设置.ActiveConnection = cn



            .CommandText =" sp_new_data"

            .CommandType = adCmdStoredProc



            .Parameters.Append .CreateParameter(" vs_system",adVarChar,adParamInput ,," system")

             .Parameters.Append .CreateParameter(" vs_operator",adVarChar,adParamInput ,," Alex")

             .Parameters.Append .CreateParameter(" vs_Msg_Error",adVarChar,adParamOutput,256)



             rs.Open MyCommand,adOpenDynamic,adLockBatchOptimistic



           设置rs = .Execute

   On Error Resume Next
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim MyCommand As New ADODB.Command

    Err.Number = 0
    cn.CursorLocation = adUseClient
    cn.ConnectionString = ConnectionString.N3
    'Abre Conexao
    cn.Open

    If Err.Number = 0 Then

        Set MyCommand = New ADODB.Command

        With MyCommand
            Set .ActiveConnection = cn

            .CommandText = "sp_new_data"
            .CommandType = adCmdStoredProc

            .Parameters.Append .CreateParameter("vs_system", adVarChar, adParamInput, , "system")
            .Parameters.Append .CreateParameter("vs_operator", adVarChar, adParamInput, , "Alex")
            .Parameters.Append .CreateParameter("vs_Msg_Error", adVarChar, adParamOutput, 256)

            rs.Open MyCommand, , adOpenDynamic, adLockBatchOptimistic

            Set rs = .Execute

           MsgBox"Value is:" &安培; rs(0)

           MsgBox "Value is: " & rs(0)

       结束用$


    rs.Close



   否则



        MsgBox("数据库不可用。错误:& Err.Description")

        End With

    rs.Close

    Else

        MsgBox ("Database is not avalible. Errror: " & Err.Description)

   结束如果



    cn.Close





   结束分

    End If

    cn.Close


    End Sub

推荐答案

尝试将包名称添加到命令文本
Try to add name of package to command text


这篇关于无法在与VBA中请求的名称或序号对应的集合中找到item的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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