asp程序中,怎样将多条记录同时修改?
查询之后是用文本框显示的,我是同时查询出来多条记录后,可以同时修改多条记录,然后把多条记录同时保存,我用下面的代码不能将记录全部修改<body><%ifrequest("...
查询之后是用文本框显示的,我是同时查询出来多条记录后,可以同时修改多条记录,然后把多条记录同时保存,我用下面的代码不能将记录全部修改
<body>
<%
if request("xg")="修改" then
bh=trim(request("bh"))
gs=trim(request("gs"))
bmmc=trim(request("bmmc"))
ghsj=trim(request("ghsj"))
gz=trim(request("gz"))
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open "select * from 工资变动表 where 员工编号='" & bh & "'",conn,3,3
do while not rs.eof
rs("员工编号")=bh
rs("所在公司")=gs
rs("部门名称")=bmmc
rs("工资")=gz
'rs("时间")=ghsj
rs.update
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script>
window.alert("修改成功!")
</script>
<%
end if
%>
<%
bh=request("bh")
set rs1=Server.CreateObject("ADODB.Recordset")
rs1.Open "select * from 工资变动表 where 员工编号='" & bh & "'",conn1,1,3
if rs1.recordcount>0 then
%>
<form method="get" action="gzxg1.asp">
<table align=center border="1" cellpadding="0" cellspacing="0"
<tr>
<td width="120" height="1">
<p align="center"><font color="#000000">更换时间</font></td>
<td width="120" height="1">
<p align="center"><font color="#000000">公司名称</font></td>
<td width="121" height="1">
<p align="center"><font color="#000000">部门名称</font></td>
<td width="120" height="1">
<p align="center"><font color="#000000">工资级别</font></td>
</tr>
<% do while not rs1.eof %>
<tr>
<td width="120" height="18">
<input type="text" name="ghsj" value="<%=rs1("时间")%>" size="20"></td>
<td width="120" height="19">
<input type="text" name="gs" value="<%=rs1("所在公司")%>" size="20"></td>
<td width="121" height="18"><input type="text" name="bmmc" value="<%=rs1("部门名称")%>" size="20"></td>
<td width="120" height="7"><input type="text" name="gz" value="<%=rs1("工资")%>" size="20"></td>
</tr>
<%
rs1.movenext
loop
%>
<%
else
response.write "没有找到记录!"
%>
<%
end if
rs1.close
set rs1=nothing
conn1.close
set conn1=nothing
%>
</table>
<p align="center">
<input type="submit" name="xg" value="修改"> </p>
<input type="hidden" name="bh" value="<%=bh%>">
</form>
</body> 展开
<body>
<%
if request("xg")="修改" then
bh=trim(request("bh"))
gs=trim(request("gs"))
bmmc=trim(request("bmmc"))
ghsj=trim(request("ghsj"))
gz=trim(request("gz"))
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open "select * from 工资变动表 where 员工编号='" & bh & "'",conn,3,3
do while not rs.eof
rs("员工编号")=bh
rs("所在公司")=gs
rs("部门名称")=bmmc
rs("工资")=gz
'rs("时间")=ghsj
rs.update
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script>
window.alert("修改成功!")
</script>
<%
end if
%>
<%
bh=request("bh")
set rs1=Server.CreateObject("ADODB.Recordset")
rs1.Open "select * from 工资变动表 where 员工编号='" & bh & "'",conn1,1,3
if rs1.recordcount>0 then
%>
<form method="get" action="gzxg1.asp">
<table align=center border="1" cellpadding="0" cellspacing="0"
<tr>
<td width="120" height="1">
<p align="center"><font color="#000000">更换时间</font></td>
<td width="120" height="1">
<p align="center"><font color="#000000">公司名称</font></td>
<td width="121" height="1">
<p align="center"><font color="#000000">部门名称</font></td>
<td width="120" height="1">
<p align="center"><font color="#000000">工资级别</font></td>
</tr>
<% do while not rs1.eof %>
<tr>
<td width="120" height="18">
<input type="text" name="ghsj" value="<%=rs1("时间")%>" size="20"></td>
<td width="120" height="19">
<input type="text" name="gs" value="<%=rs1("所在公司")%>" size="20"></td>
<td width="121" height="18"><input type="text" name="bmmc" value="<%=rs1("部门名称")%>" size="20"></td>
<td width="120" height="7"><input type="text" name="gz" value="<%=rs1("工资")%>" size="20"></td>
</tr>
<%
rs1.movenext
loop
%>
<%
else
response.write "没有找到记录!"
%>
<%
end if
rs1.close
set rs1=nothing
conn1.close
set conn1=nothing
%>
</table>
<p align="center">
<input type="submit" name="xg" value="修改"> </p>
<input type="hidden" name="bh" value="<%=bh%>">
</form>
</body> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询