数组循环保存数据问题

zy8870195 2009-04-21 09:04:06
<%
lines=20

dim array1()

redim xm_array1(lines+1)

for i=1 to lines
array1(i)= request.form("lei"+cstr(i))
next
……………………数据库链接

dim xm
for i=1 to lines
lei=xm_array1(i)
exec="insert into table([lei]) values('"+lei+"')"
conn.execute (exec)
next
%>

目前有20行表格 使用数组循环写进数据库

如何判断为空就停止循环保存?
...全文
103 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzj34 2009-04-21
  • 打赏
  • 举报
回复
for i=1 to lines
lei=xm_array1(i)
if lei<>"" then

exec="insert into table([lei]) values('"+lei+"')"
conn.execute (exec)
END IF
next
上面代码表示如果为空不写入,并取得下一个值
下面的代码表示如果为空则中止写入数据并跳出循环
for i=1 to lines
lei=xm_array1(i)
if lei="" then Exit for
exec="insert into table([lei]) values('"+lei+"')"
conn.execute (exec)
next
zy8870195 2009-04-21
  • 打赏
  • 举报
回复
谢谢你哦 if lei="" then
停止 exit for

这样判断?

next
是把这个改了吗
街头小贩 2009-04-21
  • 打赏
  • 举报
回复
vbscript怎么用+连接符,应该用&
exec="insert into table([lei]) values('"&lei&"')"
街头小贩 2009-04-21
  • 打赏
  • 举报
回复
判断空用:lei="",
停止for:Exit for

28,391

社区成员

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

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