Aspnet_membership_updatelastloginandactivitydates-Updates recent logon and active time
Source: Internet
Author: User
1 alter procedure DBO. aspnet_membership_updatelastloginandactivitydates -- updates recent logon and active time
2 @ applicationname nvarchar (256 ),
3 @ username nvarchar (256 ),
4 @ timezoneadjustment int
5as
6 begin
7 declare @ userid uniqueidentifier
8 select @ userid = NULL
9 select @ userid = U. userid
10 from DBO. aspnet_membership M, DBO. aspnet_users U, DBO. aspnet_applications
11 where loweredusername = lower (@ username) and
12 U. applicationid = A. applicationid and
13 lower (@ applicationname) = A. loweredapplicationname and
14 U. userid = M. userid
15 --- query the qualified user ID (that is, username = @ username)
16
17 if (@ userid is null) -- if it does not exist, return
18 begin
19 Return
20 end
21
22 declare @ transtarted bit
23 set @ transtarted = 0
24
25 if (@ trancount = 0) -- if the current active transaction is 0, start the transaction, set the transaction parameter to 1
26 begin
27 begin transaction
28 set @ transtarted = 1
29 end
30 else
31 set @ transtarted = 0
32
33 declare @ datetimenowutc datetime -- declare and get the current time
34 exec DBO. aspnet_getutcdate @ timezoneadjustment, @ datetimenowutc output
35
36 update DBO. aspnet_membership
37 set lastlogindate = @ datetimenowutc
38 Where userid = @ userid --- Update the Last Logon Time of this user
39
40 if (@ error <> 0) -- if an error occurs, roll back.
41 goto cleanup
42
43 update DBO. aspnet_users
44 set lastactivitydate = @ datetimenowutc
45 where @ userid = userid ---- update the last active time of this user
46
47 If (@ error <> 0) -- if an error occurs, roll back.
48 goto cleanup
49
50 if (@ transtarted = 1)
51 begin
52 set @ transtarted = 0
53 commit transaction
54 end
55
56 return
57
58 cleanup:
59
60 if (@ transtarted = 1)
61 begin
62 set @ transtarted = 0
63 rollback transaction
64 end
65
66 return-1
67
68end
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.