Results 1 to 2 of 2

Thread: Timelimit on Database Entry

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Location
    Ireland
    Posts
    8

    Question

    I am trying to put a time limit on articles in a database so that they will be automatically deleted. I created a DateExpire column in my database to contain the expiration date of the articles. Being a newcomer to the programming world I am not really sure of the code to read the expiry date and delete the article if it exceeds the date. So if anyone can pass on some workable code I would be most grateful.....

  2. #2
    Junior Member
    Join Date
    Apr 2001
    Location
    Manassas, Va.
    Posts
    18

    Use ADO to delete expired records

    Depending on the database you are using you can use ADO in VB or ASP (or any other COM-compliant language for that matter).

    Set a reference to Microsoft ActiveX Data Objects x.x Library, if you don't have this for some reason you can download it from microsoft search for MDAC.

    Code:
    Dim objConn as New ADODB.Connection
    Dim strSQL as String
    Dim strConn as String
    
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\foldername\filename.mdb" 'Connection string for an access database, string will be different for different databases
    
    strSQL = "DELETE * FROM tablename WHERE dateExpireFieldName <" & date()
    
    'Open Connection
    objConn.Open strConn
    
    'Execute SQL Statement
    objConn.Execute strSQL
    
    'Close Connection
    objConn.Close
    Set objConn = Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width