CREATE PROC spIsValidUser
@UserName varchar(50),
@Password varchar(50)
AS
IF Exists(SELECT * FROM Users where UserName=@UserName and Password=@Password)
BEGIN
return 0
END
ELSE
BEGIN
return 1
END
GO
I have created this Stored Procedure and tring to call this Stored Procedure using entity framework. Below is code in written in C#.
MyBusEntities db = new MyBusEntities();
int empQuery = db.spIsValidUser("abc", "abc@123");
spIsValidUser Stored Procedure return -1 in all case. Please let me know error.
EDIT - According to given answer, Store procedure is not used return statement because Entity Framework cannot support Stored Procedure Return scalar values out of the box..Let me know how can I send scalar data from Stored Procedure?