1
ALTER PROCEDURE dbo.aspnet_Membership_UpdateUser --更新用户数据
2
@ApplicationName NVARCHAR(256),
3
@UserName NVARCHAR(256),
4
@Email NVARCHAR(256),
5
@Comment NTEXT,
6
@IsApproved BIT,
7
@LastLoginDate DATETIME,
8
@LastActivityDate DATETIME,
9
@UniqueEmail INT,
10
@TimeZoneAdjustment INT
11
AS
12
BEGIN
13
DECLARE @UserId UNIQUEIDENTIFIER
14
DECLARE @ApplicationId UNIQUEIDENTIFIER
15
SELECT @UserId = NULL
16
SELECT @UserId = u.UserId, @ApplicationId = a.ApplicationId
17
FROM dbo.aspnet_Users u, dbo.aspnet_Applications a, dbo.aspnet_Membership m
18
WHERE LoweredUserName = LOWER(@UserName) AND
19
u.ApplicationId = a.ApplicationId AND
20
LOWER(@ApplicationName) = a.LoweredApplicationName AND
21
u.UserId = m.UserId
22
/*查询此用户的用户ID和应用程序ID*/
23![](/Images/OutliningIndicators/None.gif)
24
IF (@UserId IS NULL) --如果为空,返回1
25
RETURN(1)
26![](/Images/OutliningIndicators/None.gif)
27
IF (@UniqueEmail = 1) --如果邮件地址唯一
28
BEGIN
29
IF (EXISTS (SELECT *
30
FROM dbo.aspnet_Membership WITH (UPDLOCK, HOLDLOCK)
31
WHERE ApplicationId = @ApplicationId AND @UserId <> UserId AND LoweredEmail = LOWER(@Email)))
32
/*如果存在相同的邮件地址,返回7(用户ID 不同,所以是判断是否有相同地址的意思)*/
33
BEGIN
34
RETURN(7)
35
END
36
END
37![](/Images/OutliningIndicators/None.gif)
38
DECLARE @TranStarted BIT
39
SET @TranStarted = 0
40![](/Images/OutliningIndicators/None.gif)
41
IF( @@TRANCOUNT = 0 ) --如果当前活动事务为0,开始事务并设置事务参数为1
42
BEGIN
43
BEGIN TRANSACTION
44
SET @TranStarted = 1
45
END
46
ELSE
47
SET @TranStarted = 0
48![](/Images/OutliningIndicators/None.gif)
49
UPDATE dbo.aspnet_Membership
50
SET
51
Email = @Email,
52
LoweredEmail = LOWER(@Email),
53
Comment = @Comment,
54
IsApproved = @IsApproved,
55
LastLoginDate = DATEADD(n, -@TimeZoneAdjustment, @LastLoginDate)
56
WHERE
57
@UserId = UserId
58
/*更新表aspnet_Membership*/
59![](/Images/OutliningIndicators/None.gif)
60![](/Images/OutliningIndicators/None.gif)
61
IF( @@ERROR <> 0 )--错误则回滚
62
GOTO Cleanup
63![](/Images/OutliningIndicators/None.gif)
64
UPDATE dbo.aspnet_Users
65
SET
66
LastActivityDate = DATEADD(n, -@TimeZoneAdjustment, @LastActivityDate)
67
WHERE
68
@UserId = UserId
69
/*更新表aspnet_Users*/
70
IF( @@ERROR <> 0 ) --错误则回滚
71
GOTO Cleanup
72![](/Images/OutliningIndicators/None.gif)
73
IF( @TranStarted = 1 )
74
BEGIN
75
SET @TranStarted = 0
76
COMMIT TRANSACTION
77
END
78![](/Images/OutliningIndicators/None.gif)
79
RETURN 0
80![](/Images/OutliningIndicators/None.gif)
81
Cleanup:
82![](/Images/OutliningIndicators/None.gif)
83
IF( @TranStarted = 1 )
84
BEGIN
85
SET @TranStarted = 0
86
ROLLBACK TRANSACTION
87
END
88![](/Images/OutliningIndicators/None.gif)
89
RETURN -1
90
END
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/None.gif)
16
![](/Images/OutliningIndicators/None.gif)
17
![](/Images/OutliningIndicators/None.gif)
18
![](/Images/OutliningIndicators/None.gif)
19
![](/Images/OutliningIndicators/None.gif)
20
![](/Images/OutliningIndicators/None.gif)
21
![](/Images/OutliningIndicators/None.gif)
22
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
23
![](/Images/OutliningIndicators/None.gif)
24
![](/Images/OutliningIndicators/None.gif)
25
![](/Images/OutliningIndicators/None.gif)
26
![](/Images/OutliningIndicators/None.gif)
27
![](/Images/OutliningIndicators/None.gif)
28
![](/Images/OutliningIndicators/None.gif)
29
![](/Images/OutliningIndicators/None.gif)
30
![](/Images/OutliningIndicators/None.gif)
31
![](/Images/OutliningIndicators/None.gif)
32
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
33
![](/Images/OutliningIndicators/None.gif)
34
![](/Images/OutliningIndicators/None.gif)
35
![](/Images/OutliningIndicators/None.gif)
36
![](/Images/OutliningIndicators/None.gif)
37
![](/Images/OutliningIndicators/None.gif)
38
![](/Images/OutliningIndicators/None.gif)
39
![](/Images/OutliningIndicators/None.gif)
40
![](/Images/OutliningIndicators/None.gif)
41
![](/Images/OutliningIndicators/None.gif)
42
![](/Images/OutliningIndicators/None.gif)
43
![](/Images/OutliningIndicators/None.gif)
44
![](/Images/OutliningIndicators/None.gif)
45
![](/Images/OutliningIndicators/None.gif)
46
![](/Images/OutliningIndicators/None.gif)
47
![](/Images/OutliningIndicators/None.gif)
48
![](/Images/OutliningIndicators/None.gif)
49
![](/Images/OutliningIndicators/None.gif)
50
![](/Images/OutliningIndicators/None.gif)
51
![](/Images/OutliningIndicators/None.gif)
52
![](/Images/OutliningIndicators/None.gif)
53
![](/Images/OutliningIndicators/None.gif)
54
![](/Images/OutliningIndicators/None.gif)
55
![](/Images/OutliningIndicators/None.gif)
56
![](/Images/OutliningIndicators/None.gif)
57
![](/Images/OutliningIndicators/None.gif)
58
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
59
![](/Images/OutliningIndicators/None.gif)
60
![](/Images/OutliningIndicators/None.gif)
61
![](/Images/OutliningIndicators/None.gif)
62
![](/Images/OutliningIndicators/None.gif)
63
![](/Images/OutliningIndicators/None.gif)
64
![](/Images/OutliningIndicators/None.gif)
65
![](/Images/OutliningIndicators/None.gif)
66
![](/Images/OutliningIndicators/None.gif)
67
![](/Images/OutliningIndicators/None.gif)
68
![](/Images/OutliningIndicators/None.gif)
69
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
70
![](/Images/OutliningIndicators/None.gif)
71
![](/Images/OutliningIndicators/None.gif)
72
![](/Images/OutliningIndicators/None.gif)
73
![](/Images/OutliningIndicators/None.gif)
74
![](/Images/OutliningIndicators/None.gif)
75
![](/Images/OutliningIndicators/None.gif)
76
![](/Images/OutliningIndicators/None.gif)
77
![](/Images/OutliningIndicators/None.gif)
78
![](/Images/OutliningIndicators/None.gif)
79
![](/Images/OutliningIndicators/None.gif)
80
![](/Images/OutliningIndicators/None.gif)
81
![](/Images/OutliningIndicators/None.gif)
82
![](/Images/OutliningIndicators/None.gif)
83
![](/Images/OutliningIndicators/None.gif)
84
![](/Images/OutliningIndicators/None.gif)
85
![](/Images/OutliningIndicators/None.gif)
86
![](/Images/OutliningIndicators/None.gif)
87
![](/Images/OutliningIndicators/None.gif)
88
![](/Images/OutliningIndicators/None.gif)
89
![](/Images/OutliningIndicators/None.gif)
90
![](/Images/OutliningIndicators/None.gif)