ASP:为什么删除不了?

来源:百度知道 编辑:UC知道 时间:2024/06/04 20:01:03
提交表单文件"edit.asp"
<form action="del1.asp" method="post">
请输入要删除的学号:<input name="student_num " type="text" >
<input type="submit" value="确定"><input type="reset" value="重置">
</form>

接收文件"edit1.asp"
<!--#include file="conn.asp"-->
<%
exec="select * from students"
set rs=server.CreateObject("ADODB.recordset")
rs.open exec,conn,1,1
exec="delete * from students where student_num='"&request.form ("student_num")&"'"
conn.execute exec
%>
<%
do while not rs.eof
%>
<table width="756" height="95" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>编号</td>
<td>学号</td>
<td>姓

request.form ("student_num")是获得FROM提交的数据,你的页面代码里FROM都没有当然删除不掉了。
循环里改成下面这样。

<form name="show" method="post" action="">
<table width="756" height="95" border="0" cellpadding="0" cellspacing="0">
........此处代码省略
<tr>
<td><input type="checkbox" name="student_num" id="student_num" value="<%=rs("student_num")%>"></td>
<td><%=rs("student_id")%></td>
<td><%=rs("student_num")%></td>
<td><%=rs("name")%></td>
<td><%=rs("sex")%></td>
</tr>
........此处代码省略
</table>

</from>

代码没有问题,顺序上有点问题
exec="select * from students"
set rs=server.CreateObject("ADODB.recordset")
rs