• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Deleting Records using ASP

Hello i have created a table named LoginStatus which has the following Fields: Username, Password, Time.  

I update this Table every time that my users login on my intranet(by getting their username,Ip address and login time) so as to have some connection status of my intranet...

Up to here is working just fine...

Now what i want to do is when the users click the logout button i want their entry which was added during login to be deleted from the Table. I want the ASP or SQL command that will enable me to do this.

Thank you
0
globemast
Asked:
globemast
1 Solution
 
JennyRoCommented:
Format is this:

DELETE FROM table_name
WHERE column_name = some_value

So you could put username as colum_name and then the persons actual username as some_value

Eg: WHERE username = JennyRo
0
 
nareeratCommented:
file : Frm.asp
       call asp file when user logout
...
         ...delete.asp?user=<%=Rs("user")%>
           
...
------------------------------------------------
'*** you have to connection at database.inc.asp already ,so #include file in delete.asp
'*** if not, add connection in delete.asp file
file : delete.asp
<%Response.buffer=true%>
<!-- #include file="../../includes/database.inc.asp" -->
<html>
<head>
<%
Set Conn = getConnection()
Set Rs   = Server.CreateObject("ADODB.Recordset")
SQLStmn  = "SELECT * FROM TABLE_NAME where Username = "&"'"& request("user")&"'"
     Rs.open SQLStmn, Conn, 1, 3
        If   not(Rs.BOF and Rs.EOF)  Then            
         Rs.Delete
     End if
     Rs.Close
     Conn.Close
%>
</head>
</html>
0
 
globemastAuthor Commented:
Well i have a logout button and i have created a logout.asp file in which i have the following SQL statment.

Delete from LoginStatus where Username='"+Session("User")"'

I want when the key to be pressed the user to be logged out and also be to be transfered to the logout.asp where it will get the message that he has been logout..

i used the Server.Transfer("logout.asp") command but i does not work properly...

I realy don't have a clue how to do this to work and also to tranfer the user to the logout.asp page

Please help me...Thank you very much
0
 
nareeratCommented:
hi
 You used the script right.
I think that maybe something wrong on your script.(not sure  ......asp  or  logout.asp  wrong)
Try again
        build new page : test.asp
               <html>
               <head>
               </head>
               <body>asdfasdfasfasdf</body>
               </html>
         ---------------------
--cut old script and  add script
<% Server.Transfer("test.asp") %>    

if no error then something wrong on logout.asp
 http://www.aspfree.com/asp/servertransfer.asp
hope this can help you  :)
bye

         
0
 
hmtrivediCommented:
i dont know why server.transfer is giving an error to you.

however please verify that the user records are deleted from your database before they are redirected to the logout page.

also, if server.transfer doesnt work, try response.redirect instead.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now