ADO output Parameter help.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using ado 2.6 in ac97. The code below gave me the return values in my
two output paramenters under debug view, but the values did not get assign
into the variables( intRetCode & strRetMes). What went wrong?

Thanks!

Dim intRetCode As Integer
Dim strRetMes As String
.....
With cmd
Set .ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "OP_checkValidDiscounts"
.Parameters.Append cmd.CreateParameter("@CO_Number",
adVarChar, adParamInput, 15, rsTmp!head_order_nbr)
.Parameters.Append cmd.CreateParameter("@RetCode",
adInteger, adParamOutput, 15, intRetCode)
.Parameters.Append cmd.CreateParameter("@RetMsg", adVarChar,
adParamOutput, 100, strRetMes)
.Execute

End With
 
homer,

If you read the values of the parameters after the command execution then
you will get the values you need:

With cmd
...
.Execute
ntRetCode = .Parameters("@RetCode").Value
ntRetMsg = .Parameters("@RetMsg").Value
End With

Unlike the default behaviour for A97 the variables that you have used to
create parameters are not sent by reference - they are passed ByVal - that is
the reason that they are not receiving the returned values after the command
execution.

HTH.
 
Back
Top