467,149 Members | 1,324 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,149 developers. It's quick & easy.

Question on a 'Hits' column in User Table

I currently have a User table in my database that has the columns:


I created a page on the website in a DotNetNuke reports module where a query is executed that displays all of the user information. I've gotten that to execute properly. I have now created another column in the database table titled 'Hits'

I am trying to get Hits to be incremented by 1 based off of a change in LastActivityDate. So basically each time a user is active on my page a 1 will be added to their 'Hits' in the database table. I've never posted here so if this is in the wrong forum I apologize. Any help would be appreciated!


I have tried this and it executes but it will obviously add a hit each time the page is loaded which is not what I am looking for.

SET Hits=Hits+1
WHERE Users.LastActivityDate >= '12/23/2008 3:10:38 AM'
Dec 23 '08 #1
  • viewed: 1386
1 Reply
Expert 2GB
How do you update LastActivityDate column? Do you update it every time the user access the table? If you do, just update the hits every time you update the LastActivityDate column.

Something like:
Expand|Select|Wrap|Line Numbers
  2. UPDATE Users
  3. SET Hits=Hits+1,LastActivityDate = getdate()
  4. WHERE UserName = VariableFromYourSite
  6. .
Your options are:

Create a stored proc that will handle all this


Build the query from your front end and execute dynamically.

Dec 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

18 posts views Thread by Guinness Mann | last post: by
20 posts views Thread by Jack Schitt | last post: by
28 posts views Thread by cjobes | last post: by
9 posts views Thread by David Eades | last post: by
3 posts views Thread by maximisedk | last post: by
5 posts views Thread by jehugaleahsa@gmail.com | last post: by
1 post views Thread by pitjpz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.