Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Tuesday, March 20, 2012

Automatic SQL db update at set time?

I would like to limit the number of pages a user can view on my website each day. The users logs in and I can count the number of pages viewd in a field but i want to know how i can set the page count field to reset to 0 at the end of the day (ie midnight). Is it possible to do this? and if so how? Thanks.You can set up a job to run a stored proc at that time every day using SQL Server Agent (find it in SQL Server Enterprise Manager)

A better way might be to log pageviews with a timestamp, and then you can allow X pages within any 24 hour period - simply count the pageviews in the log newer than getdate() - 1 and check it against the limit.

Does that help?|||The server will be a shared sql server and i don't have access to creating new jobs, so I think your second suggestion would be best but not sure how to implement it. Do you have an example or a link to where I can find an example? Thanks|||Normally that should not be a problem - I use a shared database server (one of those cheap .net hosters) and I can create jobs just fine.

Think about my other solution if you really can't create jobs - it's better (I believe) and it does not require a scheduled job.

Check BOL for examples of creating jobs.

Sunday, March 11, 2012

Automatic content expiry

Hi All,

I have a job coming up which involves me creating a vacancy system for our website.

I (think) I'll only need one table:

ID (PK)
JobTitle
JobLocation
Salary
Hours
JobDescription
ValidFrom (Date/Time)
ValidTo (Date/Time)

I'll display this data using a C#.Net repeater but I was wondering how I can automatically strip the page of the jobs that have gone past their expiry date? Is is straightforward to achieve?

Thanks in advance,
Brett

Add a where condition to your select statement to bring only the valid Jobs e.g.:

select * from Jobs where getDate() < ValidTo

Hope this was helpful

Eyad Salamin

|||

Thanks Eyad,

I didn't think it would be that simple!

Brett