我尝试使用存储过程更改用户密码。
控制器:
public ActionResult ChangeMyPassword(MyModel model)
{
int UserId = Convert.ToInt32(Session["UserId"]);
context.sp_ChangePassword(UserId, model.NewPassword);
context.SaveChanges();
return view();
}
存储过程:
USE [CRM_DEMO]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_ChangePassword]
@Id int ,
@NewPassword Varchar(50)
AS
Update UserTable
set
UserPassword = @NewPassword
WHERE UserId= @Id
有用; 但是,密码不会在数据库中更改。我错过了什么?