[attach]560[/attach] 大家都知道偶是个初学者,呵呵。
我希望能够实现一个删除数据库行的功能,于是在每行前面加了一个单选按钮的控件,希望选定后执行删除操作,进而实现功能。删除部分的逻辑代码应该是没有问题的,可是点击删除书架的按钮后,只有刷屏,呵呵。
请各位高手指点,感激不尽!
[attach]564[/attach]
改了一下: delshelf.asp <!--#include file="Connections/conn.asp" -->
<% dim bookshelfno dim conn
set conn=Server.CreateObject("ADODB.Connection") conn.open MM_conn_STRING bookshelfno=replace(request.form("del"),", ","','") 'response.write("delete from 书架表 where bookshelfno in('" & bookshelfno & "')") conn.execute("delete from 书架表 where bookshelfno in('" & bookshelfno & "')") set conn=nothing Response.write("删除成功!<a href='modifyshelf.asp'>返回</a>") %>
modifyshelf.asp(其中的单选按钮改成了复选,可以同时删除多条数据)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="Connections/conn.asp" --> <% Dim modify Dim modify_numRows
Set modify = Server.CreateObject("ADODB.Recordset") modify.ActiveConnection = MM_conn_STRING modify.Source = "SELECT * FROM 书架表" modify.CursorType = 0 modify.CursorLocation = 2 modify.LockType = 1 modify.Open()
modify_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index
Repeat1__numRows = 10 Repeat1__index = 0 modify_numRows = modify_numRows + Repeat1__numRows %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <style type="text/css"> <!-- .style1 { font-family: "华文新魏"; font-size: 36px; color: #666666; } .style2 {font-size: 18px} --> </style> </head>
<body> <div align="center"> <p class="style1">修改书架 </p> <% If Not modify.EOF Or Not modify.BOF Then %> <table width="594" height="86" border="1"> <form name="form1" method="post" action="delshelf.asp"> <tr> <td width="20" height="42"> </td> <td width="153"><div align="center"><span class="style2">书架编号</span></div></td> <td width="164"><div align="center"><span class="style2">书架名称</span></div></td> <td width="107"><div align="center"><span class="style2">库存</span></div></td> <td width="116"><div align="center"><span class="style2">总量</span></div></td> </tr> <% While ((Repeat1__numRows <> 0) AND (NOT modify.EOF)) %> <tr> <td><input name="del" type="checkbox" value="<%=(modify.Fields.Item("bookshelfno").Value)%>"></td> <td> <%=(modify.Fields.Item("bookshelfno").Value)%> </td> <td><%=(modify.Fields.Item("bookshelfname").Value)%></td> <td><%=(modify.Fields.Item("total").Value)%></td> <td><%=(modify.Fields.Item("stock").Value)%></td> </tr> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 modify.MoveNext() Wend %> </form> </table> <% End If ' end Not modify.EOF Or NOT modify.BOF %>
<input type="button" name="Submit" value="删除书架" onclick="javascript:form1.submit();">
<form name="form3" method="post" action=""> <input type="submit" name="Submit3" value="修改书架"> </form> <form name="form4" method="post" action="manage.asp"> <input type="submit" name="Submit2" value="返回"> </form> <p> </p> </div> </body> </html> <% modify.Close() Set modify = Nothing %>