帮忙看看程序问题

zty8008_2008 2008-04-23 03:36:00
<%
sql="Select * from TravelInfo where TI_Area is not null order by TI_ID Asc"
Set rs=server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
b=""
c=""
i=1
While Not rs.eof
If(i<>1) then
If Right(b,1)<>"," Then
b=b+rs("TI_Area")+","
Else
b=b+rs("TI_Area")
End If
End if
c=b
rs.movenext
i=i+1
Wend
Response.write c+"<br><br>"

%>
我想判断b如果没有","加上","有的就不加了,但是总是不行,rs("TI_Area")都是文字,帮忙看看吧
...全文
64 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用楼主 zty8008_2008 的帖子:]
<%
sql="Select * from TravelInfo where TI_Area is not null order by TI_ID Asc"
Set rs=server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
b=""
c=""
i=1
While Not rs.eof
If(i <>1) then
If Right(b,1) <>"," Then
b=b+rs("TI_Area")+","
Else
b=b+rs("TI_Area")
End If
End if
c=b
rs.movenext
i=i+1
Wend
Response.write c+" <br> <br>"

[/Quote]
你这么写肯定是错的哈!
只要把
If(i <>1) then
If Right(b,1) <>"," Then
b=b+rs("TI_Area")+","
Else
b=b+rs("TI_Area")
End If
这部分只要改成
If b<>"" Then
b=b+","+rs("TI_Area")
Else
b=rs("TI_Area")
End If
zty8008_2008 2008-04-23
  • 打赏
  • 举报
回复
谢谢,解决了,给分了
myvicy 2008-04-23
  • 打赏
  • 举报
回复
<%
sql="Select * from TravelInfo where TI_Area is not null order by TI_ID Asc"
Set rs=server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
b=""
c=""
i=1
While Not rs.eof
b=b+rs("TI_Area")+","
rs.movenext
Wend
c=mid(b,1,len(b)-1)'去掉最后的,
a=split(c,",")
for i=0 to ubound(a)
Response.write a(i)+"<br>"
next
%>
lij1997 2008-04-23
  • 打赏
  • 举报
回复
是呀,这个b是没有值呀?
是不是这样?
If Right(rs("TI_Area"),1) <> "," Then
b=rs("TI_Area")&","
end if
zty8008_2008 2008-04-23
  • 打赏
  • 举报
回复
楼上朋友,下面用split怎么用,在给c这个字符串用","分隔,每个在打印出来,谢谢
md5e 2008-04-23
  • 打赏
  • 举报
回复

While Not rs.eof
If i <>1 then
If Right(b,1) <>"," Then
b=b+rs("TI_Area")+","
Else
b=b+rs("TI_Area")
End If
else
b=rs("TI_Area")
End if
c=c + b
rs.movenext
i=i+1
Wend

Response.write c+" <br> <br>"
md5e 2008-04-23
  • 打赏
  • 举报
回复
If Right(b,1) <>"," Then

b 没有值啊

If Right(rs("TI_Area"),1) <>"," Then
zty8008_2008 2008-04-23
  • 打赏
  • 举报
回复
然后把c用","分隔,我知道用split,但是不知道怎么用

28,391

社区成员

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

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