Here's one way of getting the return value of a SQL Server stored procedure:
Dim returnValueConnection As SqlConnection
Dim returnValueCommand As SqlCommand
Dim returnValueParameter As SqlParameter
Dim returnValue As Object
' Instantiate and initialize command
returnValueCommand = New SqlCommand("RETURN_VALUE",
returnValueConnection)
returnValueCommand.CommandType = CommandType.StoredProcedure
' Instantiate, initialize and add parameter to command
returnValueParameter =
returnValueCommand.Parameters.Add("@RETURN_VALUE", _
SqlDbType.Int)
' Indicate this is a return value parameter
returnValueParameter.Direction = ParameterDirection.ReturnValue
' Get RETURN_VALUE
returnValue = returnValueCommand.ExecuteScalar()