Thursday, March 29, 2012

Server Side Timer?

Please could someone point me in the right direction?

I'm new to ASP.NET although I'm an experienced VB developer who has recently moved to .NET. Not too experienced with SQL either.

I am writing my first web site using ASP.NET and need some advise please. I want a serverside event to trigger at a given interval, say every hour on the hour, to update a SQL server DB table. This is not caused by any client interaction just at the server on the hour - the results will be shown in the browser but not triggered by it.

How would you go about doing this - ASP.NET, SQL etc? Any help would be gratefully received since I am rather lost lol!

Thanks.

It can't be done by asp.net web application.

I've read about sending email by scheduling. According to that article, first, you should build windows-based application or console application to update SQL server DB table. Then you will need to add that application in Windows Scheduler.

Hope it'll help.

Do a bit of reading up on the SQLAgent... roll it into a scheduled task, which you can do in MS SQL. Its beyond the scope of this site so I'd suggest a bit of googling or simple head over to the MS newsgroups/communities and look for the SQL groups.


I am not really sure that what you are trying to update but you can use the META REFRESH tag to refresh your page and as soon as the page refreshes you use AJAX to fire the server side method and update the database. But then again not sure what you will send in the database and because of refresh a flicker will happen in the browser.

Thanks for all the suggestions. Writing a console app sounds like a good idea - do hosts (haven't sorted yet) allow that sort of thing? I thought as much Curt - I'll have a readup about it, thanks.

Users of my site can basically post ads (limited number of slots) which have a limited life span (although it's much more complicated than that!). I want a routine to periodically update a stack of ads and move them to the next slot as time goes by, mail users for possible renewal etc.

A simple solution for now could be to call an update routine whenever somebody views the ads page which updates the table if necessary. This could obviously be a problem if 1000s of people start to visit but I don't think I need to worry about that yet!

Just thought of a really silly question: If I have an ASP.NET app that talks to a SQL DB and performs updates etc based on user driven events like button clicks etc. Does the DB code need to be clever and lock tables etc in a multi user system i.e. web app?

0 comments:

Post a Comment