Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Automatically delete records from database after a period of time


Reply
 
Thread Tools Display Modes
  #1  
Old 10-28-2009, 12:49 AM
pu8y pu8y is offline
Newcomer
 
Join Date: Jun 2009
Posts: 7
Default Automatically delete records from database after a period of time


Hi all,

I am writing a website in ASP.net and database MySQL.
I want to delete the certain records from my database after a number of days, how can I accomplish that?

For example user has inserted many rows of records into the database table everyday. But for each record, it must be automatically be deleted after 30days.
Reply With Quote
  #2  
Old 10-28-2009, 01:59 AM
gibra's Avatar
gibra gibra is offline
Junior Contributor
 
Join Date: Apr 2008
Location: Italy
Posts: 380
Default

The table must have a Date column type (i.e. DataCreation) which you store the data of record creation.

Next you can delete the records

Code:
WHERE DateDiff("d", DataCreation, CurrentDate)  >= NumberDays
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->