ALTER PROCEDURE dbo.aspnet_Membership_ChangePasswordQuestionAndAnswer
@ApplicationName NVARCHAR(256),
@UserName NVARCHAR(256),
@NewPasswordQuestion NVARCHAR(256),/*新密码提示问题*/
@NewPasswordAnswer NVARCHAR(128)/*新密码提示问题答案*/
AS
BEGIN
DECLARE @UserId UNIQUEIDENTIFIER /*声明变量用户ID*/
SELECT @UserId = NULL /*设置为NULL*/
SELECT @UserId = u.UserId /*查询aspnet_Users的UserId给@UserId*/
FROM dbo.aspnet_Membership m, dbo.aspnet_Users u, dbo.aspnet_Applications a
WHERE LoweredUserName = LOWER(@UserName) AND
u.ApplicationId = a.ApplicationId AND
LOWER(@ApplicationName) = a.LoweredApplicationName AND
u.UserId = m.UserId
/*三个表分别通过ApplicationId和UserId连接(个人感觉用INNER 也是 可以的吧,不过
CSS里好象都放在WHERE里了),加上用户名这个条件.*/
IF (@UserId IS NULL) /*如果符合条件的用户ID不存在则返回1*/
BEGIN
RETURN(1)
END
UPDATE dbo.aspnet_Membership
SET PasswordQuestion = @NewPasswordQuestion, PasswordAnswer = @NewPasswordAnswer
WHERE UserId=@UserId
RETURN(0) /*如果存在则更新数据库并返回0(更新条件为查询出的用户ID)*/
END
@ApplicationName NVARCHAR(256),
@UserName NVARCHAR(256),
@NewPasswordQuestion NVARCHAR(256),/*新密码提示问题*/
@NewPasswordAnswer NVARCHAR(128)/*新密码提示问题答案*/
AS
BEGIN
DECLARE @UserId UNIQUEIDENTIFIER /*声明变量用户ID*/
SELECT @UserId = NULL /*设置为NULL*/
SELECT @UserId = u.UserId /*查询aspnet_Users的UserId给@UserId*/
FROM dbo.aspnet_Membership m, dbo.aspnet_Users u, dbo.aspnet_Applications a
WHERE LoweredUserName = LOWER(@UserName) AND
u.ApplicationId = a.ApplicationId AND
LOWER(@ApplicationName) = a.LoweredApplicationName AND
u.UserId = m.UserId
/*三个表分别通过ApplicationId和UserId连接(个人感觉用INNER 也是 可以的吧,不过
CSS里好象都放在WHERE里了),加上用户名这个条件.*/
IF (@UserId IS NULL) /*如果符合条件的用户ID不存在则返回1*/
BEGIN
RETURN(1)
END
UPDATE dbo.aspnet_Membership
SET PasswordQuestion = @NewPasswordQuestion, PasswordAnswer = @NewPasswordAnswer
WHERE UserId=@UserId
RETURN(0) /*如果存在则更新数据库并返回0(更新条件为查询出的用户ID)*/
END