ASP字段数据替换
文件:c1.asp c1a.asp表:users2 字段:nos1 数据:“1”
c1.asp 提交给 c1a.asp 可以替换段内任何一个关键字,可全句或个别替换,但不能提交空数据。我想保留现在这替换功能又想可以用空数据替换旧数据,好象是一种字段清空功能吧。请高手帮忙修改一下。谢谢!
c1.asp :
<!--#include file="conn.asp"-->
<html>
<head>
<link href="font.css" rel="stylesheet">
<meta http-equiv="Content-Language" content="zh-cn">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body text="#000000">
<div align="center"><center>
<form method="POST" action="c1a.asp">
<table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse"
width="100%" bordercolordark="#C0C0C0" bordercolorlight="#C0C0C0" height="104">
<tr class="main2">
<td width="25%" height="21" align="center" bgcolor="#FFFFFF">
旧<font style="font-size: 9pt">数据:</a></font></td>
<td width="47%" height="21" align="left" bgcolor="#FFFFFF"><span style="font-size: 9pt">
<input
type="text" name="oldurl" size="30" value="1"></span></td>
<td width="27%" height="84" align="center" bgcolor="#FFFFFF" rowspan="2"><span
style="font-size: 9pt">
<input type="submit" value="提交"
style="font-family: 新细明体, 宋体, Arial; height:20px;background-color:#D4D0C8"
onMouseOver="this.style.backgroundColor='#FFC864'"
onMouseOut="this.style.backgroundColor='#D4D0C8'" name="adaction"></span></td>
</tr>
<tr>
<td width="25%" height="21" align="center" bgcolor="#FFFFFF">新数据</font></td>
<td width="47%" height="21" align="left" bgcolor="#FFFFFF"><span style="font-size: 9pt">
<input
type="text" name="newurl" size="30"> </sp an></td>
</tr>
</table>
</center></div> </form>
</body></html></body></html>
c1a.asp:
<!--#include file="conn.asp"-->
<link href="font.css" rel="stylesheet">
<body text="#000000">
<%
newurl=trim(request("newurl"))
oldurl=trim(request("oldurl"))
set rs=server.createobject("adodb.recordset")
sqltext="select * from users2 where id=1 "
rs.open sqltext,conn,3,3
rs("oldurl")=trim(request("newurl"))
rs.update
rs.close
response.write "<p align=center>"
response.write "数据"
response.write oldurl
response.write "清空,默认为1从新开始:"
response.write newurl
response.write "<br><br>"
set rs=server.createobject("adodb.recordset")
sqltext="select * from users2 order by id "
rs.open sqltext,conn,3,3
do while not rs.eof
rs("nos1")=Replace(rs("nos1"),oldurl,newurl)
rs.update
Rs.moveNext
loop
rs.close
set rs=server.createobject("adodb.recordset")
sqltext="select * from users2 order by id "
rs.open sqltext,conn,1,1
%>
</p>
<div align="center">
<center>
<table border="1" cellspacing="1" style="border-collapse: collapse" width="50%" id="AutoNumber1">
<%do while not rs.eof%><tr>
<td width="20%"><%=rs("id")%></td>
<td width="80%"><%=rs("nos1")%></td>
</tr>
<%Rs.moveNext
loop
rs.close%>
</table>
</center></div>