我有这个代码
' 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为零:/