I have the following very basic stored procedure:
CREATE PROCEDURE [dbo].[GetNumberToProcess]
AS
RETURN 999
I then have some code using Enterprise Library to run and get the return value:
Dim cmd As DbCommand
Dim ResultValue as String
Dim lDBCommand as String = "dbo.GetNumberToProcess"
Dim actionDB As Sql.SqlDatabase = New Sql.SqlDatabase(lConnectionString)
cmd = actionDB.GetSqlStringCommand(lDBCommand)
Dim SQLreturnValue As New SqlParameter("RETURN_VALUE", DbType.Int32)
SQLreturnValue.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(SQLreturnValue)
' Execute the command and put the result into the ResultValue for later processing
actionDB.ExecuteNonQuery(cmd).ToString()
ResultValue = cmd.Parameters("RETURN_VALUE").Value.ToString
Problem is that all I ever get back as ResultValue is "0" when I should get "999" (the Stored Proc is very cut down just so that I can get to the bottom of why it's not working).
According to the multiple examples I've seen on the web this should work.
Anyone got any suggestions as to why it doesn't?