为什么多条记录时执行,而一条记录不执行,在线等!!!!

hgxlucky 2003-06-27 06:02:56
为什么多条记录时执行,而一条记录不执行,在线等!!!!
一条记录时,值根本就不变

<%
if request("xg")="修改" then
bh=trim(request("bh"))
qssj=trim(request("qssj"))
array1=split(qssj,", ")
px=trim(request("px"))
array5=split(px,", ")
i=0
set conn=Server.CreateObject("ADODB.Connection")
conn.open "driver=SQL Server;Server=192.168.0.63;UID=hgx;PWD=hgx;Database=rsda"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open "select * from 培训记录表 where 员工编号='" & bh & "'",conn,3,3
do while not rs.eof
sql ="update 培训记录表 set 培训='" & array5(i) & "', 时间='" & array1(i) & "', where 编号='" & rs("编号") & "'"
conn.execute(sql)
i=i+1
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%
end if
%>
...全文
52 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
philorlogin 2003-06-28
  • 打赏
  • 举报
回复
我想也肯定是匹配出了问题,可能一条记录的时候,根本就没有进入循环!!你在仔细看看,多用些打印的语句,以便知道程序到底执行到了那里!!
caoshangfei 2003-06-28
  • 打赏
  • 举报
回复
我已经改好。发给你邮箱了,查收。
michael_monkey 2003-06-28
  • 打赏
  • 举报
回复
数组array1的长度和rs取出的记录条数不一定匹配吧。你这个程序有问题,如果rs记录条数为10,而数组array1长度为5,想想~~

aloxy 2003-06-28
  • 打赏
  • 举报
回复
检查循语句。你的循环条件后面加上
or rs.bof
nchen123 2003-06-27
  • 打赏
  • 举报
回复

sql ="update 培训记录表 set 培训='" & array5(i) & "', 时间='" & array1(i) & "', where 编号='" & rs("编号") & "'"
之后插入:
response.write "<br>i=" & i
response.write "<br>sql=" & sql
看看输出结果是否正确。

循环条件最好改成:
do while not rs.eof and i<ubound(array1) and i< ubound(array5)
...
xiaobird1 2003-06-27
  • 打赏
  • 举报
回复
看看一条记录时是否进入了DO WHILE循环
jsjwql 2003-06-27
  • 打赏
  • 举报
回复
i=1看看

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧