do while……loop循环删除记录

本文展示了一个使用VBScript和ADO组件在ASP中实现循环删除指定条件记录的示例。该示例通过do while...loop循环遍历table2表中的记录,并删除序号大于等于16的所有记录,最后更新并显示了剩余的记录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
  
<head>  
  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  
<title>rs_del.asp(do while……loop循环删除记录)</title>  
  
</head>  
  
  
  
<body>  
  
<%   
  
set conn=server.CreateObject("adodb.connection")   
  
conn.open "provider=sqloledb;data source=localhost;database=employee;uid=sa;password="   
  
  
  
set rs=server.CreateObject("adodb.recordset")   
  
source="table2"  
  
rs.open source,conn,1,3   
  
  
  
do while not rs.eof   
  
  if rs("序号").value>=16 then   
  
    rs.delete   
  
  end if   
  
  rs.movenext   
  
loop   
  
rs.updatebatch   
  
rs.close   
  
rs.open "select * from table2",conn,1,3   
  
  
  
response.write"<table border=1 width=80%/>"   
  
  response.write"<tr align=center>"   
  
    for i=0 to rs.fields.count-1   
  
      response.write"<td>"&rs(i).name&"</td>"   
  
    next   
  
  response.write"</tr>"   
  
     
  
  do while not rs.eof   
  
  response.write"<tr align=center>"   
  
  for i=0 to rs.fields.count-1   
  
    response.write"<td>"&rs(i).value&"</td>"   
  
  next   
  
  rs.movenext   
  
  response.write"</tr>"   
  
  loop   
  
  response.write"</table><br>"   
  
     
  
rs.close   
  
set rs=nothing  
  
conn.close   
  
set conn=nothing  
  
%>  
  
</body>  
  
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值