Execute后,可以取參數對象中的有Output的那個參數的值:比如: Create Proc TEST(@A int OUTPUT) AS SET @A=100以下在VB中 '*********** Private Sub Command1_Click() Dim iCmd As ADODB.Command
Set iCmd = New ADODB.Command With iCmd .ActiveConnection = cnn '預先打開的連接 .CommandType = adCmdStoredProc .CommandText = "TEST" .Parameters.Refresh .Execute MsgBox .Parameters("@A") End With
Create Proc TEST(@A int OUTPUT)
AS
SET @A=100以下在VB中
'***********
Private Sub Command1_Click()
Dim iCmd As ADODB.Command
Set iCmd = New ADODB.Command
With iCmd
.ActiveConnection = cnn '預先打開的連接
.CommandType = adCmdStoredProc
.CommandText = "TEST"
.Parameters.Refresh
.Execute
MsgBox .Parameters("@A")
End With
End Sub結果應該為100