ASP编程如何将同一数据库多条记录显示,并可同时修改(只需设置一键提交全部修改,不需逐条保存)

2025-02-06 01:33:31
推荐回答(2个)
回答1:

我给你个我今天编写的程序吧
你看了自己照着改就可以了<%id=request("id")
xztype=trim(request("xztype"))
if id<>"" and xztype<>"" then
id=int(id)
%>









<%sql="select * from bftable where xztype='"&xztype&"' and idd="&id
rs.open sql,conn,1,3
if rs.recordcount=0 then
rs.close
response.write""
response.end
else
soon=rs.recordcount
do while not rs.eof
i=i+1
if i=2 then
i=0
end if
if i=1 then
xx=""
end if
if i=0 then
xx="bgcolor=#cccccc"
end if
%>
>






<%rs.movenext
loop
soon=i+1
if (soon mod 2)=0 then
xx="bgcolor=#cccccc"
else
xx=""
end if
end if
response.write""
%>
性别 年龄 保险金额 缴费期限
保费
请先添加保费后再修改保费
">
"> "> "> ">


<%else
end if%>
上面是显示多条记录
下面是修改多条记录
<%
id=request("id")
idd=request("idd")
xztype=request("xztype")
sex=request("sex")
age=request("age")
bxmoney=request("bxmoney")
jfterm=request("jfterm")
bf=request("bf")

sex=split(sex,",")
for i = 0 to ubound(sex)
sex(i)=sex(i)
next
age=split(age,",")
for i = 0 to ubound(age)
age(i)=age(i)
next
bxmoney=split(bxmoney,",")
for i = 0 to ubound(bxmoney)
bxmoney(i)=bxmoney(i)
next
jfterm=split(jfterm,",")
for i = 0 to ubound(jfterm)
jfterm(i)=jfterm(i)
next
bf=split(bf,",")
for i = 0 to ubound(bf)
bf(i)=bf(i)
next
id=split(id,",")
for i = 0 to ubound(id)
id(i)=id(i)
next
for i=0 to ubound(bf)
if sex(i)<>"" or age(i)<>"" or bxmoney(i)<>"" or jfterm(i)<>"" or bf(i)<>"" then
sql="select * from bftable where id="&trim(id(i))
rs.open sql,conn,1,3
rs("sex")=trim(sex(i))
rs("age")=trim(age(i))
rs("bxmoney")=trim(bxmoney(i))
rs("jfterm")=trim(jfterm(i))
rs("bf")=trim(bf(i))
rs.update
rs.close
end if
next
%>

回答2:

数据表A
里面有 :
产品编号(id)、 产品名(ProName)、添加时间(AddDate)

比如 A.asp 修改页面 B.asp 保存页面
a.asp

<%

set rs=server.createobject("adodb.recordset")
rsMark.open "select * from A ",conn,1,1
%>


" size="30">

" size="30">




b.asp

<%sql = "Update A set Proname='"&trim(request.form("Proname "))&"', AddDate=’” &trim(request.form("AddDate "))&”’”
conn.execute(sql)
response.Write ""
response.End
%>

这样改表A里面的所有记录的 ProName 和 AddDate 都一样的 你改改看