我有以下存储过程:
ALTER PROCEDURE [dbo].[BK_NUMBER]
(@Category NUMERIC(38, 0))
WITH EXECUTE AS CALLER
AS
DECLARE @RunningNumber Int
DECLARE @min Int
DECLARE @max Int
DECLARE @newRunningNumber Int
BEGIN
SELECT @RunningNumber = RunningNumber
FROM PARKMARKENNUMMER
WHERE PARKMARKENTYP_ID = @Category
UPDATE PARKMARKENNUMMER
SET RUNNINGNUMBER = @RunningNumber + 1
WHERE PARKMARKENTYP_ID = @Category
SELECT @newRunningNumber = RunningNumber
FROM PARKMARKENNUMMER
WHERE PARKMARKENTYP_ID = @Category
RETURN @newRunningNumber;
End;
我尝试@newRunningNumber
使用这个 VB 代码:
Dim sqlConnection As New SqlConnection(MSSQL_Helper.strConnectionBookit)
Dim command As New SqlCommand("BK_NUMBER", sqlConnection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@Category", SqlDbType.Int).Value = ID
Dim returnParameter As SqlParameter = command.Parameters.Add("RetVal", SqlDbType.Int)
returnParameter.Direction = ParameterDirection.ReturnValue
sqlConnection.Open()
command.ExecuteNonQuery()
sqlConnection.Close()
Dim returnValue As Integer = returnParameter.Value
Return returnValue
但它总是返回“0”。我究竟做错了什么?