I have an SP that returns integer value. The SP hasn't defined any return variable and it is directly returning value for e.g. return -1, return -2
I tried the following code but it gives exception:
Code
AseParameter retval = cmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int); retval.Direction = ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery(); //This line throws exception
Exception
NotSupportException
BindParameter - Int
How to read return value?
EDIT
Stored Procedure
IF OBJECT_ID('dbo.MySP') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.MySP
IF OBJECT_ID('dbo.MySP') IS NOT NULL
PRINT '<<< FAILED DROPPING PROCEDURE dbo.MySP >>>'
ELSE
PRINT '<<< DROPPED PROCEDURE dbo.MySP >>>'
END
go
create procedure MySP
@param1 char(60),
@param2 char(3),
@param3 int,
@param4 char(4)
as
declare
@somefield1 char(1),
@somefield2 datetime,
If @param1 is null
return -1
If @param2 != "L"
return -2
more code here.....