I have this SQL Server stored procedure:
@UserName VARCHAR(MAX),
@Result INT
AS
BEGIN
SET NOCOUNT ON;
SELECT LoginID
FROM Personnel
WHERE LoginID = @UserName AND Administrator = 'Y'
SET @Result = @@ROWCOUNT
RETURN @Result
END
When I test it I get the results back as expected, I get either 1 row or a 0 row count.
I call the stored procedure from my C# application with this code:
private void ValidateUser(string user)
{
using (ComplaintsEntities db = new ComplaintsEntities())
{
var t = db.AAGetAdminStatus(user,0);
}
}
When I test with a good user account I should get a result of 1
and if my user is not admin I should get a result of 0
. When I inspect the return value in the C# code, it always returns -1
. How can I get this to work?