Learning purposes: Learn to database basic Operations 3 (delete records)
to get to the point, we'll see the program directly.
exec= "Delete * from guestbook where id=" &request.form ("id")
This sentence completes the deletion of the record, although the lock record has a unique representation ID of the record, we have previously established Font color= "#0000ff" > database when the system to our primary key, the name is number, because the name is not very convenient, you can modify the ID, do not modify the words is
exec= "Delete * from Guestbook where number = "&request.form" ("id")
Let's look at the complete code: a form is passed to an ASP file with an ID, and then the ASP file deletes the ID.
<form name= "Form1" method= "Post" action= "example7.asp"
Delete:
<input type= "text" name= "id" >
<input type= "Submit" name= "Submission" value= "commit"
</form>
Example7.asp:
<%
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" &server.mappath ("Example3.mdb")
exec= "Delete * from guestbook where number =" &request.form ("id")
Conn.execute exec
%>
I added a example72.asp in the example, and example4.asp almost, is added an ID field, you can run this file to see the ID of all the records and want to delete the record ID, delete records can also be reviewed through this file. By the end of the day, we will integrate all these things. Everyone would not need such a cumbersome operation.
Example72.asp:
<%
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" &server.mappath ("Example3.mdb")
Exec= "SELECT * FROM Guestbook"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open exec,conn,1,1
%>
<title> Untitled Document </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" text= "#000000" >
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<%
Do as not rs.eof
%><tr>
<td><%=rs ("number")%></td>
<td><%=rs ("name")%></td>
<td><%=rs ("tel")%></td>
<td><%=rs ("message")%></td>
<td><%=rs ("Time")%></td>
</tr>
<%
Rs.movenext
Loop
%>
</table>
</body>