Test your technical skills online, appear in Virtual Interview and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Make friends on DotNetFunda.com and expand your network!
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Forums Author
Sun, 20-Apr-2014 Authors
All Time Authors
Jayakumars
3930
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)

how to insert login and logout times

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

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



Reply | Reply with Attachment

=> Scroll below for responses


Comments or Responses

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.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.

Found interesting? Add this to: