循环遍历结果集并在ASP Classic中添加create逗号分隔字符串

时间:2010-06-12 12:00:38

标签: asp-classic loops resultset

这是我的ASP Classic:

set irs  = recordset(sql,PageDB)            
    if not irs.eof then

        dim new_list
        new_list = ""

        do while not irs.eof

            'Add irs("name") to new_list and separate by comma      

        irs.movenext

        loop

    end if

kill(irs)

如何将irs(name)添加到new_list并用逗号分隔?

1 个答案:

答案 0 :(得分:2)

set irs  = recordset(sql,PageDB)            
    if not irs.eof then

        dim new_list
        new_list = ""

        do while not irs.eof

            new_list = new_list & irs("name") & ","     

        irs.movenext

        loop

        new_list = left(new_list, len(new_list)-1)

    end if

kill(irs)