日期:2014-05-17  浏览次数:20851 次

怎么判断是最后一条数据的时候不显示逗号?
C# code
Dim rslou,nm
nm = Easp.R("n","1:10")
Set rslou = Easp.db.GetRecordBySQL("SELECT TOP "&nm&" chrloupan, shouloutel, avgprice, filepath, chraddress FROM mh163k_house_loupan WHERE iskill = 1 ORDER BY loupanid DESC")

While Not rslou.eof
a="["
while not rslou.eof and not rslou.bof
b="{""id"":"&rslou("shouloutel")&",""title"":"&rslou("shouloutel")&"},"

rslou.movenext()
a=a&b
wend
a=a&"]"
response.write(a)
Wend
Easp.db.C(rslou)


------解决方案--------------------
VB code

'不要去判断,影响效率,直接去掉最后一个
b=left(b,len(b)-1)
'或
b=mid(b,1,len(b)-1)
a=a&b

------解决方案--------------------
VBScript code
strComma = ""
while not rslou.eof and not rslou.bof
    b="{""id"":"&rslou("shouloutel")&",""title"":"&rslou("shouloutel")&"}"
    rslou.movenext()
    a=a & strComma & b
    strComma = ","
wend