...

View Full Version : Delete a table (database) when it's open?



Esona
01-20-2003, 09:40 PM
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


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)


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.

raf
01-22-2003, 09:01 AM
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


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum