This topic is locked

Tracking input with user name

3/12/2007 8:23:23 AM
ASPRunnerPro General questions
S
stealthwifi author

Hello,

I am trying to come up with a way for the currently logged on user name and current date/time to be sent to the database every time a user adds data for edits data.

I figured this would go on the after update event and send the user name and now date/time but i do not know how to get the user name to send. Any help is much appreciated.
Cheers,

Stealth-

J
Jane 3/13/2007

Stealth,
here is a sample code:

Sub AfterAdd()

'** Insert a record into another table ****

strSQLInsert = "insert into TableName (UserName, CurrentDate) values ('" & Session("UserID") & ", now())"

dbConnection.Execute strSQLInsert
End Sub



where TableName is your actual table name, UserName and CurrentDate are your actual field names.

S
stealthwifi author 3/13/2007

Jane,
Thank you very much for your help!

I came across one syntax error in the code and just wanted to fix it here in case any one else used the code. After the ("UserID") & " it wanted a ' to close it. I added to the code below. Thanks again it works great now. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=16210&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

Sub AfterAdd()

'** Insert a record into another table ****

strSQLInsert = "insert into TableName (UserName, CurrentDate) values ('" & Session("UserID") & "', now())"

dbConnection.Execute strSQLInsert
End Sub