Get Return Value from Stored procedure in asp.net

前端 未结 6 1176
既然无缘
既然无缘 2020-12-10 11:19

i have a stored procedure

ALTER PROC TESTLOGIN
    @UserName varchar(50),
    @password varchar(50)
As
Begin
    declare @return int;

    set @return  = (S         


        
6条回答
  •  被撕碎了的回忆
    2020-12-10 11:47

    Procedure never returns a value.You have to use a output parameter in store procedure.

    ALTER PROC TESTLOGIN
    @UserName   varchar(50),
    @password   varchar(50)
    @retvalue int output
     as
     Begin
        declare @return     int 
        set @return  = (Select COUNT(*) 
        FROM    CPUser  
        WHERE   UserName = @UserName AND Password = @password)
    
       set @retvalue=@return
      End
    

    Then you have to add a sqlparameter from c# whose parameter direction is out. Hope this make sense.

提交回复
热议问题