xyla
Posts: 17
|
| Posted: 06/17/2006, 2:34 AM |
|
Is there a way to auto delete old calendar entries.
I know how to filter them out but would like to delete the automaticly to keep the database clean.
I'm using asp.net vb with an MySQL database.
_________________
http://xyla.nl | Your Solution Provider |
 |
 |
peterr
Posts: 5971
|
| Posted: 06/17/2006, 10:19 AM |
|
Based on http://www.google.com/search?hl=en&lr=&safe=off&q=mysql...date+older+than you can try:
DELETE FROM tablename WHERE (TO_DAYS(NOW()) - TO_DAYS(datefield))>30
Examples of executing custom SQL are at http://docs.codecharge.com/studio3/html/ProgrammingTech...eCustomSQL.html
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
xyla
Posts: 17
|
| Posted: 06/17/2006, 10:54 AM |
|
Thank you Peterr!
_________________
http://xyla.nl | Your Solution Provider |
 |
 |
xyla
Posts: 17
|
| Posted: 06/17/2006, 11:47 AM |
|
The query works fine!
DELETE FROM calendar WHERE (TO_DAYS(NOW()) - TO_DAYS(start_date))>30
But I realy don't know how to automate it. I would like to see the query executed every time a page with a grid opens or every time a recordform is submitted.
_________________
http://xyla.nl | Your Solution Provider |
 |
 |
peterr
Posts: 5971
|
| Posted: 06/17/2006, 4:28 PM |
|
I think that you can use that example from CCS documentation in any event, for example "Before Show" of the page, or maybe "After Initilize". It's something to try and test. CCS documentation talks about the "After Execute Update" event, so I don't see why "After Execute Insert" wouldn't work either (after a record was submitted).
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
xyla
Posts: 17
|
| Posted: 06/18/2006, 12:24 AM |
|
I used the following code in the "After Execute Insert" event of the record, this works great.
Dim Request As HttpRequest = HttpContext.Current.Request
Dim NewDao As DataAccessObject = Settings.piekiec_enDataAccessObject
Dim Sql As String = "DELETE FROM calendar WHERE (TO_DAYS(NOW()) - TO_DAYS(start_date))>30"
NewDao.RunSql(Sql)
_________________
http://xyla.nl | Your Solution Provider |
 |
 |