Get Return Value from Stored procedure in asp.net

前端 未结 6 1173
既然无缘
既然无缘 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:50

    you can try this.Add the parameter as output direction and after executing the query get the output parameter value.

      SqlParameter parmOUT = new SqlParameter("@return", SqlDbType.Int);
      parmOUT.Direction = ParameterDirection.Output;
      cmd.Parameters.Add(parmOUT);
      cmd.ExecuteNonQuery();
      int returnVALUE = (int)cmd.Parameters["@return"].Value;
    

提交回复
热议问题