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

把记录集中所有数据的 rs("ID") 循环后,如何得到 诸如:"22,23,25,26,27,28,29,30,31,32," 这样的字符串

以下方法,把数据集全部读出来了,

      set   rs=server.createobject( "adodb.recordset ")
      sql= "select   *   from   questions "
      rs.open   sql,conn,3,2    

然后,有一个字段是   ID   ,

我要怎么循环程序,才能把记录中所有   rs( "ID ")   连成这样的字符串:

"22,23,25,26,27,28,29,30,31,32, "

------解决方案--------------------
<%
str = " "
while not rs.eof
str = str & rs( "ID ") & ", "
rs.movenext
wend
response.write str
%>
------解决方案--------------------
Do While Not rs.EOF
str = str + rs.Fields( "ID ").Value & ", "
Loop
------解决方案--------------------
str = " "
Do While Not rs.EOF
str = str + rs.Fields( "ID ").Value & ", "
rs.MoveNext
Loop