I wrote a stored procedure to return a count. But I got a null value. Can anybody tell me where is the problem in my stored procedure.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[ValidateUser]
@UserName varchar(50),
@Password varchar(50),
@Num_of_User int output
AS 
BEGIN
  SET NOCOUNT ON;
  SELECT @Num_of_user =COUNT(*) 
    FROM login
   WHERE username = @UserName 
     AND pw = @Password
  RETURN
END
                you are setting the value into the variable @num_of_user. add select @num_of_user after the query
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[ValidateUser]
    @UserName varchar(50),
    @Password varchar(50),
    @Num_of_User int output
AS
BEGIN
    SET NOCOUNT ON;
     SELECT @Num_of_user =COUNT(*) 
         FROM login
         WHERE username=@UserName AND pw=@Password
     SELECT @Num_of_user
return
END
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With