Search
MVC Online Training
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Sun, 21-Sep-2014 Authors
All Time Authors
Jayakumars
4170
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)
 Forum Post

how to insert login and logout times

Vineeth1311
Posted by Vineeth1311 under Sql Server on 6/10/2009 11:06:14 PM | Views : 2630 | Status : [Member] | Replies : 4


hi

how to insert logout time in to sql server +when i close the browser?



Posted by: Vuyiswamb on: 6/11/2009 [Member] [MVP] [Administrator] NotApplicable

Good Afternoon Vineeth1311

The Simple thing you can do is to Insert a new record when the user logs into and when he logout Update the Field of datetime and set it to getdate() , which is the current time.

1 insert statement and 1 Update statement when the user logs out.

Thank you for posting at DotnetFunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vineeth1311 on: 6/11/2009 [Member] Starter

And also I want to insert the time when user closes the browser

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 6/11/2009 [Member] [MVP] [Administrator] NotApplicable

Good Morning Vineeth1311

yes lets say i have a Table called timelogging defined like this

Create table timelogging 

(
ID int identity(100,01) Primary key not null ,
Username varchar(20) null,
LoginTime DateTime null,
LogoutTime DateTime null
)


in this Case when the User logs in you will insert a new Record and like this

insert into timelogging (Username,LoginTime)
values (@Username,GetDate())


and when the user Closes the Application by logging out , now you don't insert a new record but you Update a Field "LogoutTime like this


Update timelogging
set LogoutTime =Getdate()
where Username = @Username


Thank you Again For Posting at Dotnetfunda


Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bubbly on: 10/23/2009 [Member] Bronze

Hello,

You can update the time on close event of window.

++
Thanks & Regards,
Deepika

Vineeth1311, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response


Found interesting? Add this to: