Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello again you good people,

Back with another question. I have built a webform that will check the database for records with 'start time' less that 15 minutes from now, and another check on the same page for records with 'end time' less than 15 minutes from now. Then bind the data to separate gridview.

If row count for the gridview is greater than 0, the page sends email to admin.

The idea is to send a reminder email saying the booking will start in 15 minutes, and another one to say the booking will end in 15 minutes.

Question is, how do I get this page to automatically run every 15 minutes so that its always checking the db? I have it working, but it will need to automatically run every 15 minutes.

Thanks for you help.
Posted
Comments
[no name] 2-Jul-15 12:00pm    
Use a scheduled task or a windows service.
Awoldeselassie 2-Jul-15 12:08pm    
ok, thanks. will look into it.
Sergey Alexandrovich Kryukov 2-Jul-15 13:39pm    
There is no such concept, "run a page". What are you trying to achieve, ultimately?
—SA
Awoldeselassie 2-Jul-15 15:39pm    
true....the answer to the question SA is ultimately, I would like to send a reminder e-mail automatically. I got that working using webform(i can explain how if you like), but i need it to run automatically without me starting it. if you have a better suggestion, i would appreciate it.
Awoldeselassie 2-Jul-15 16:02pm    
I created a webform and added gridview1. On the behind code, on page load, open connection and read data using a stored procedure. The stored procedure gets records (asset bookings) that have 'starting time' within the next 15 min. Then bind the data to gridview1. then count the Rows in gridview1, if count is greater than 0, then render gridview1 in HTML email body and send it. Oooooooshhh. mouth full.

i have a second gridview to perform the same operation for 'end time' too. but i need this to run every 15 min automatically.

I got a feeling that there is a better way of doing this!!!!

Scott Hanselman wrote a blog post[^] last year comparing the different options for scheduling background tasks in ASP.NET applications.
 
Share this answer
 
Comments
Awoldeselassie 2-Jul-15 15:50pm    
thank you Richard, very detailed blog, will have a read through
Sergey Alexandrovich Kryukov 2-Jul-15 17:01pm    
Looks useful, a 5.
—SA
For a quick solution you could use the built in html way of doing it:
HTML
<head>
<meta http-equiv="refresh" content="15">
</meta></head>

http://www.w3schools.com/tags/att_meta_http_equiv.asp[^]

But as mentioned in a comment a scheduled task of some sort will be the best way to go.

On the database side of things you may want to look into SQL Server Agent.

These links may help:
https://msdn.microsoft.com/en-us/library/ms189237.aspx[^]

https://msdn.microsoft.com/en-us/library/ms187061(v=sql.110).aspx[^]

http://stackoverflow.com/questions/5471080/how-to-schedule-a-job-for-sql-query-to-run-daily[^]
 
Share this answer
 
Comments
Awoldeselassie 2-Jul-15 15:49pm    
oo thanks, will try it let you know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900