如何从存储过程获取返回值,使用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")
这篇关于如何从存储过程中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!