I' so lost.... This is my stored proc:
@User_ID INT,
@Form_NAME NVARCHAR(25)
AS
BEGIN
DECLARE @Count int = 0
DECLARE @myReturnCode INT
SELECT @Count = COUNT (tblForms.Form_Name)
FROM tblForms INNER JOIN
tblForms_Roles_MTM ON tblForms.Form_Id = tblForms_Roles_MTM.Form_Id INNER JOIN
tblRoles ON tblForms_Roles_MTM.Role_Id = tblRoles.Role_Id INNER JOIN
tblUsers_Roles_MTM ON tblRoles.Role_Id = tblUsers_Roles_MTM.Role_Id
WHERE (tblUsers_Roles_MTM.User_Id = @User_ID AND tblForms.Form_Name = @Form_NAME)
IF @Count = 0
BEGIN SET @myReturnCode = 0 END
ELSE
BEGIN SET @myReturnCode = 1 END
SELECT @myReturnCode as ReturnCode
END
In my code behind I call the procedure passing the 2 params and then :
...
con.Open();
int ReturnCode = (int)cmd.ExecuteScalar();
Response.Write(ReturnCode);
But myReturnCode is always 0.
When I execute the proc in SSMS is I see in "results" 2 values :
I guess that ExecuteScalar is returning the value of "Return Value".
So how do I get the value of "ReturnCode"?
I've been googling it for the past 36 hours. The answer is probably out there but....where? Couldn't find it.
Any hint will be greatly appreciated.
(Win-7 , SS-2014 , VS-2013)