我正在尝试将sql存储过程的输出值提取到调用程序中。存储过程是:
ALTER PROCEDURE selectdediario (@descr varchar(20),@disp decimal output)
AS
begin
SET NOCOUNT ON;
SELECT @disp = sum(disp)
FROM diario
WHERE descr = @descr;
return
end
我收到的输出是:
Stored Procedure: mala2.dbo.Selectdediario
Return Code = 0
Output Parameter(s):
@disp = 676
我的visual basic子程序在vb6.0中:
Private Sub cmdApendTable_Click()
' declare the variable to to receive the output value of the procedure
Dim vdescr As String
vdescr = "gas sousa"
Dim vdisp As Currency
Call StartConnection
Set cmdEmpresa = New ADODB.Command
With cmdEmpresa
.Parameters.Append .CreateParameter("@descr", adVarChar, adParamInput, 20, vdescr)
.Parameters.Append .CreateParameter("@disp money OUTPUT", adCurrency, adParamoutput)
.ActiveConnection = conexao
.CommandType = adCmdStoredProc
.CommandText = "Selectdediario"
Set rsEmpresa = .Execute
End With
Debug.Print disp
End Sub
程序要求参数@disp
所以我添加了0值。我希望将@disp
的值放入我的程序中。