how to insert login and logout times

Posted by Vineeth1311 under Sql Server on 6/10/2009 | Views : 2998 | Status : [Member] | Replies : 4
hi

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




Responses

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

Up
0
Down
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

Up
0
Down
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

Up
0
Down
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

Up
0
Down
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

 

Have you tried Aspose: http://aspose.com/file-tools

Login to post response