Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete a table (database) when it's open? - nevermind

    EDIT- I figured it out, thanks anyways =) (I'll still post it when I finish)
    Thought I'd pester you guys some more =)

    Ok, I'm on a roll for that 'delete user on exit' business, but I've run into yet another problem.
    This is the code I'm using
    Code:
    Rs.Open "SELECT * from Onlines", Conn,1,3
    Do While Not Rs.Eof
    If Datediff("n",right(Rs("Last_Action"), 11), Time) => "5" then
    Now, what I need to do is be able to delete that table, but it's already open.. is there any way I can do that? this is what I want it to finally look like (I know it won't work, just examples)
    Code:
    Rs.Open "SELECT * from Onlines", Conn,1,3
    Do While Not Rs.Eof
    If Datediff("n",right(Rs("Last_Action"), 11), Time) => "5" then
    delete table
    end if
    Rs.MoveNext
    Loop
    Any ideas will help me out =)
    I'll post the script when I'm done so all you other people that are trying to delete entries on exit can do it with a little more ease.
    Last edited by Esona; 01-20-2003 at 09:26 PM.
    Only when we die do we realize the importance of life

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don’t quite get the problem. Why do you want to delete the table ? What’s this ‘the table is already open stuff’.
    When you use ‘delete’; only the content (data) will be deleted, not the structure --> the table will still exist after executing (but will be empty).
    To remove the table, use ‘drop’. Something like
    Code:
    sql = "DROP TABLE thetable"
    sql=replace(sql,"thetable",request.form("Table"))
    
    condb.Execute sql
    I don’t think it matters that you already executed a select-statement on that table. The recordset and connection objects or open, but the table normally not.

    Still, why dropping the table? Can’t you just insert the stuff in a general table with an extra variable to group the records from one user (like his username or userID or an unique identifier your application generated and inserted in the database + registered in the session-object or cookie or something like that) and just remove the rows from that user when he exits? (I do more a less this way, but I don’t delete the records on exit. I use an extra variable (‘status’) that can have different values (registered-confirmed-paid-….) This way, users can logout (or drop out for whatever reason) but can still confirm his orders or whatever in a later session.


  •  

    Posting Permissions

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