如何从存储过程中获取值
如何从存储过程获取返回值,使用VB6
和SQL Server
.
How to get a return value from store procedure, using VB6
and SQL Server
.
存储过程
ALTER PROCEDURE [dbo].[DayAttn]
@Attn VARCHAR(12) OUTPUT
AS
BEGIN
SELECT @Attn = MAX(id)
FROM table1
RETURN @Attn
END
VB6
conn.Execute "exec DayAttn '" '" & Attn & "'"
以上代码显示错误.
推荐答案
这段代码应该向你展示如何在 VB6/ADO 经典中做到这一点:
This code should show you how to do it in VB6/ADO classic:
Set cmdTemp = New ADODB.Command
Set cmdTemp.ActiveConnection = gcnxMain
cmdTemp.Parameters.Append cmdTemp.CreateParameter("Ret", adInteger, adParamReturnValue)
cmdTemp.CommandType = adCmdStoredProc
cmdTemp.CommandText = "Procname"
cmdTemp.Execute
MsgBox "Return Value: " & cmdTemp.Parameters("Ret")
相关文章