我有一个存储过程
ALTER PROC TESTLOGIN
@UserName varchar(50),
@password varchar(50)
As
Begin
declare @return int;
set @return = (SELECT COUNT(*)
FROM CPUser
WHERE UserName = @UserName
AND Password = @password);
return @return;
End
并在 C# 中
SqlConnection con = db.con;
SqlCommand cmd = new SqlCommand("TESTLOGIN", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter parm = new SqlParameter("@return", SqlDbType.Int);
parm.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(parm);
cmd.Parameters.Add(new SqlParameter("@UserName", txtUserName.Text.ToString().Trim()));
cmd.Parameters.Add(new SqlParameter("@password", txtPassword.Text.ToString().Trim()));
cmd.ExecuteNonQuery();
con.Close();
int id = Convert.ToInt32(parm.Value);
但它总是返回 0。请帮我解决这个问题