Deleting a Record
a record in your database is very similar to updating, so we're going
to use the same code for the first page called users.asp. The only thing
that will need changed in the users.asp page is the link for each user.
This time, we need to point it to the page that will delete the record.
So change the link in your users.asp page from:
href='edit.asp?ID=" & RS("userID") & " '>" & RS("username") & "</a>
<a href='deleteuser.asp?ID=" & RS("userID") & " '>" & RS("username")
then save this as duser.asp. All
we need now is one more page to do the actual deleting, so that's all
this tutorial will contain. If you don't know how to create the duser.asp
page that we mentioned, check out our previous tutorial on updating
a record in a database. Here we go.
passing the ID of the record we want to delete, we use our DELETE statement.
<% Option Explicit %>
Dim ID, objConn, RS, SQL
ID = trim(request("ID"))
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "DELETE * FROM users WHERE userID = " & ID & " "
RS.Open SQL, objConn
You have successfully deleted a user. <a href="duser.asp">Click
here</a> to continue.
too hard, eh? Have fun, just don't go crazy with it or you won't have
a database to work with after too long. Remember to post any questions
on our messageboard. See ya next time!