VBA получить выходной параметр из хранимой процедуры - PullRequest
0 голосов
/ 10 октября 2018

У меня есть этот код

 ' Insert item into database
    With cmd
        .ActiveConnection = conn

        .CommandText = "exec myschema.usp_procedure" _
        & "'" & user & "'," _
        & "''" ' output id

        .CommandType = adCmdText
        .CommandTimeout = 300
        .Execute

        Dim outputId As Integer
        outputId = cmd.Parameters("outputId").Value

    End With

Я получаю ошибку

Item cannot be found in the collection corresponding to the requested name or ordinal

Что не так?Как я могу получить параметр @outputId int OUTPUT?

  • Хранимая процедура выполнена правильно, я могу видеть новые элементы в базе данных

еще одна попытка

Dim outputId As Integer
     With cmd
            .ActiveConnection = conn

            .CommandText = "exec edi.usp_ImportOrderHeader" _
            & "'" & user & "'," _
            & "''"

            .Parameters.Append .CreateParameter("outputId", adNumeric, adParamOutput, , outputId)

            .CommandType = adCmdText
            .CommandTimeout = 300

            .Execute
        End With

хранимая процедура выполняется без ошибок, но outputId равен нулю: /

...