---------------------------------
ALTER PROCEDURE sp_2
@p int output,
@p1 int,
@p2 int
as
set @p = @p1+@p2
return 99
---------------------------------
Function returnP()
Dim cmd As New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
'@return_value"这个参数在输入参数的最前面,名称是固定的
cmd.Parameters.Append cmd.CreateParameter("@return_value", adInteger, adParamReturnValue)
'输入和输出的参数顺序同存储过程的参数顺序
cmd.Parameters.Append cmd.CreateParameter("@p", adInteger, adParamOutput)
cmd.Parameters.Append cmd.CreateParameter("@p1", adInteger, adParamInput,,1)
cmd.Parameters.Append cmd.CreateParameter("@p2", adInteger, adParamInput,,2)
cmd.CommandText = "sp_2"
cmd.CommandType = adCmdStoredProc
cmd.Execute
Dim i As Integer
For i = 0 To cmd.Parameters.Count - 1
Debug.Print cmd.Parameters(i).Name & "=" & cmd.Parameters(i).Value
Next i
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
End Function
'----------测试---------
? returnP()
@return_value=99
@p=3
@p2=2
@p1=1