关于split函授分割recordset的问题

liti66 2008-12-08 06:52:49
表“call”下的字段“detail”下数据格式为“1,2,3,3,4”
想读取detail字段在页面显示1 2 3 3 4
------------------------------------------------
<%set rs=server.CreateObject("adodb.recordset")
sql="select * from call order by id desc"
rs.open sql,conn,1,1%>

<%
str1=rs("detail")
aa= split(str1,",")
for i=0 to Ubound(aa)
response.write(aa(i)&" ")
next
%>
----------------------------------------------
然后运行,报错
Microsoft VBScript compilation (0x800A0410)
Invalid 'for' loop control variable


我该怎么做?
...全文
95 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
半山闲人 2009-02-25
  • 打赏
  • 举报
回复
表“call”下的字段“detail”下数据格式为“1,2,3,3,4”

你这里面的数据的逗号是中文逗号,你分割的时候用的是英文逗号,是不是这里的问题啊?
cqsangs 2009-02-25
  • 打赏
  • 举报
回复
楼主是不是 反复使用了同名的循环变量嵌套?? 如
Dim i
for i=0 to 10
'do something...
for i=0 to 1000 '这里,重用了外部For循环的变量i,建议换成 j
'do something
Next
Next
liti66 2008-12-08
  • 打赏
  • 举报
回复
没变化........
文盲老顾 2008-12-08
  • 打赏
  • 举报
回复
你输出一个 ubound(aa) 看看是多少
liti66 2008-12-08
  • 打赏
  • 举报
回复
谢谢楼上的

但是还是出错

错误类型:
Microsoft VBScript compilation (0x800A0410)
Invalid 'for' loop control variable
/selection/main/admin.asp, line 91, column 6
for i = 0 to Ubound(aa)
-----^
文盲老顾 2008-12-08
  • 打赏
  • 举报
回复
<%
set rs = server.CreateObject("adodb.recordset")
sql = "select * from call order by id desc"
rs.open sql,conn,1,1

str1 = rs("detail") & ""
aa = split(str1,",")
if isArray(aa) then
for i = 0 to Ubound(aa)
response.write aa(i) & " "
next
else
response.write aa
end if
%>


养成良好的代码书写习惯
liti66 2008-12-08
  • 打赏
  • 举报
回复
楼上能不能完整的写一下下??谢谢
搬运工865 2008-12-08
  • 打赏
  • 举报
回复
同上上
文盲老顾 2008-12-08
  • 打赏
  • 举报
回复
看代码应该是 ubound() 返回的 -1,即,不是数组
文盲老顾 2008-12-08
  • 打赏
  • 举报
回复
加个数组判断

if isArray(aa) then
for ....
next
end if
liti66 2008-12-08
  • 打赏
  • 举报
回复
谢谢楼上的,我一定要用split的话呢?
cjl520xx 2008-12-08
  • 打赏
  • 举报
回复
直接用replace不就好了?
<%
str1=rs("detail")
aa= replace(str1,","," ")
response.write(aa)

%>

28,390

社区成员

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

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