想要循环调用代码如下:
do while 
tempcontent=tempcontent&"  <tr>" 
tempcontent=tempcontent&"    <td height=20 valign=top> <img src=news/images/pot_"&s_pic&".gif align=absmiddle>"
tempcontent=tempcontent&"      <a href='news/news/view.asp?id="&rsa("id")&"' target=_blank title='"&rsa("title")&"'>"&atempTitle&"</a>"&o_char&newimg&hot
tempcontent=tempcontent&"    </td>"
tempcontent=tempcontent&"  </tr>"
rsa.movenext
loop
请问do while循环应该怎么写啊? 

解决方案 »

  1.   

      可以在后台实现,,
      如:string str="";
         str="<table><tr><td>列名</td>";
         for(int i=0;i<=list;i++)
    {
      str+="";
    }response.write(str);
      

  2.   

    do while (not rsa.eof)  '括号中是一个bool类型的表达式
    'your business logic operation
    rsa.movenext
    loop要注意的是,do while...loop和while...wend的不同之处在于,前者是先不判断就直接进行一次操作,完了再回到while判断是否执行下一次,而后者则是从进入循环前每次都要判断
      

  3.   

    所以当你纪录为空的时候,有可能会导致死循环,最好先判断一下
    if not rs.eof then
      

  4.   

    do while not rsa.eof
    tempcontent=tempcontent&"  <tr>" 
    tempcontent=tempcontent&"    <td height=20 valign=top> <img src=news/images/pot_"&s_pic&".gif align=absmiddle>"
    tempcontent=tempcontent&"      <a href='news/news/view.asp?id="&rsa("id")&"' target=_blank title='"&rsa("title")&"'>"&atempTitle&"</a>"&o_char&newimg&hot
    tempcontent=tempcontent&"    </td>"
    tempcontent=tempcontent&"  </tr>"
    rsa.movenext
    loop
    rsa.close
    set rsa = nothing我这样写了,可是出不来效果???
      

  5.   

    代码是这样的
    <!--#include file="../inc/setup.asp" -->
    <!--#include file="../inc/CheckClass.inc.asp" -->
    <!--#include file="../dbconnect/news.inc.asp" --><%
    s_cataid=RtnReplaceInt(trim(request("cataid")),0)
    s_words=RtnReplaceInt(trim(request("words")),15)
    s_num=RtnReplaceInt(trim(request("num")),8)
    s_pic=RtnReplaceInt(trim(request("pic")),7)
    s_pica=RtnReplaceInt(trim(request("pica")),8)
    s_count=RtnReplaceString(trim(request("l_c")))
    s_date=RtnReplaceString(trim(request("l_d")))
    s_more=RtnReplaceString(trim(request("l_m")))
    s_special=RtnReplaceString(trim(request("l_s")))
      
    if s_cataid <> 0 then
    set rsk=server.CreateObject("adodb.recordset")
    sqlk="Select * from newscata where id="&s_cataid
    rsk.Open sqlk,conn,1,3
    if not rsk.eof then
    krootid = rsk("rootid")
    ktitle =rsk("title")
    end if
    rsk.close
    set rsk=nothing
    end if allcataid = ""
    if s_cataid <> 0 then
    set rsm=server.CreateObject("adodb.recordset")
    sqlm="Select * from newscata"
    rsm.Open sqlm,conn,1,3
    do while not rsm.eof
    mrootid = rsm("rootid")
    gotoid = rsm("id")
    if InStr(krootid,",") < 1 then
    mmrootid = split(mrootid,",")
    if mmrootid(0) = krootid then
    allcataid = allcataid&" or cataid =" &gotoid
    end if
    else
    if InStr(mrootid,krootid) > 0 then
    allcataid = allcataid&" or cataid =" &gotoid
    end if
    end if
    rsm.movenext
    loop
    rsm.close
    set rsm = nothing
    end if
    allcataid = trim(Mid(allcataid,4))
    tempcontent="<table cellspacing=0 cellpadding=0 width=94% align=center border=0>"
    tempcontent=tempcontent&"  <tbody>"
    tempcontent=tempcontent&"  <tr>"
    tempcontent=tempcontent&"    <td height=4></td>"
    tempcontent=tempcontent&"  </tr>" set rsa=server.createobject("adodb.recordset")
                sqlm="Select * from newscata"
    rsm.Open sqlm,conn,1,3
    if s_special ="ok" then
    if s_cataid = 0 then
    sqla = "select Top "&s_num&" * from news where special order by sortid desc"
    sqlh = "select Top 3 * from news where special order by hits desc"
    else
    sqla = "select Top "&s_num&" * from news where ("&allcataid&") and special order by sortid desc"
    sqlh = "select Top 3 * from news where ("&allcataid&") and special order by hits desc"
    end if
    else
    if s_cataid = 0 then
    sqla = "select Top "&s_num&" * from news order by sortid desc"
    sqlh = "select Top 3 * from news order by hits desc"
    else
    sqla = "select Top "&s_num&" * from news where ("&allcataid&") order by sortid desc"
    sqlh = "select Top 3 * from news where ("&allcataid&") order by hits desc"
    end if
    end if

    rsa.Open sqla,conn,1,3
    if rsa.EOF or rsa.BOF then
    tempcontent=tempcontent&" <tr><td>暂时没有任何信息!</td></tr>"
    end if
    do while not rsa.EOF
    if len(Trim(rsa("title")))>cint(s_words) then
    atempTitle = Left(RtnReplaceString(Trim(rsa("title"))),s_words)&"..."
        else
    atempTitle =RtnReplaceString(Trim(rsa("title")))
    end if
    if s_count = "ok" then
    if s_date= "ok" then
    o_char ="["&FormatDateTime(rsa("addtime"),vbshortdate)&" 浏览:"&rsa("hits")&"]"
    else
    o_char ="[浏览:"&rsa("hits")&"]"
    end if
    else
    if s_date= "ok" then
    o_char ="["&FormatDateTime(rsa("addtime"),vbshortdate)&"]"
    else
    o_char =""
    end if
    end if

    if cdate(FormatDateTime(rsa("addtime"),vbshortdate)) = cdate(FormatDateTime(now(),vbshortdate)) or cdate(FormatDateTime(rsa("addtime"),vbshortdate))+1 = cdate(FormatDateTime(now(),vbshortdate)) then
      newimg=" <img src=news/images/new.gif align=absmiddle>"
    else
      newimg=""
    end if

    hot=""
    set rsh=server.createobject("adodb.recordset")
    rsh.Open sqlh,conn,1,3
    do while not rsh.eof
    if rsa("id")=rsh("id") and not(cdate(FormatDateTime(rsa("addtime"),vbshortdate)) = cdate(FormatDateTime(now(),vbshortdate)) or cdate(FormatDateTime(rsa("addtime"),vbshortdate))+1 = cdate(FormatDateTime(now(),vbshortdate))) then
      hot=" <img src=news/images/hot1.gif align=absmiddle>"
    end if
    rsh.movenext
    loop
    rsh.close
    set rsh=nothing
    do while ’想用这个循环语句,实现新闻循环调用
    tempcontent=tempcontent&"  <tr>" 
    tempcontent=tempcontent&"    <td height=20 valign=top> <img src=news/images/pot_"&s_pic&".gif align=absmiddle>"
    tempcontent=tempcontent&"      <a href='news/news/view.asp?id="&rsa("id")&"' target=_blank title='"&rsa("title")&"'>"&atempTitle&"</a>"&o_char&newimg&hot
    tempcontent=tempcontent&"    </td>"
    tempcontent=tempcontent&"  </tr>"
    rsa.movenext
    loop
    rsa.close
    set rsa = nothingdo while ’想用这个循环语句,实现新闻循环调用
    怎么写啊?
      

  6.   

    晕死。。最好你没有输出啊。
    rsa.movenext
    loop
    rsa.close
    set rsa = nothing
    '结束后,输出变量,你用的是变量
    Response.Write(tempcontent)
      

  7.   

    +1do while not rsa.eof ’想用这个循环语句,实现新闻循环调用
      

  8.   

    用document.write("<%=tempcontent%>");输出的只能输出一行