帮忙看看程序问题

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")都是文字,帮忙看看吧
...全文
46 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
[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,但是不知道怎么用
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-04-23 03:36
社区公告
暂无公告