10 days Learning ASP Seventh Day [ASP Tutorial Foundation Series]

Source: Internet
Author: User
Tags unique id
Learning objectives: Learn the basic operation of the database 3 (delete records)
Straight to the point, everyone directly to see the program.
exec= "Delete * from guestbook where id=" &request.form ("id")
The above sentence completes the operation of deleting records, however, the lock record with the record unique ID, we set up the database in front of the system to our primary key, the name is number, because the name is not very convenient, we can modify the ID, do not modify the words is
exec= "Delete * from guestbook where number =" &request.form ("id")
Here we look at the complete code: a form passed to the ASP file an ID, and then this ASP file deleted this ID.
<form name= "Form1" method= "Post" action= "example7.asp" >
Delete
<input type= "text" name= "id" >
<input type= "Submit" name= "Submission" value= "submitted" >
</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>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.