0

I have this code

 ' 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

I am getting error

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

Whats wrong ? How can i retrieve the @outputId int OUTPUT parameter ?

  • The stored procedure is executed properly, i can see new items in database

another try

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

store procedure execute without error, but outputId is zero :/

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Muflix
  • 6,192
  • 17
  • 77
  • 153
  • Possible duplicate of [VBA, ADO.Connection and query parameters](https://stackoverflow.com/questions/10352211/vba-ado-connection-and-query-parameters) – ashleedawg Oct 10 '18 at 10:21
  • @ashleedawg but that is input parameter, i need output. – Muflix Oct 10 '18 at 10:47

0 Answers0