我现在有这么一段代码:
<%  
Response.ContentType = "text/html"
Response.Addheader "Content-Type","text/html; charset=gb2312"
set conn = Server.CreateObject("Adodb.Connection")  
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\AspWeb\wwwroot\qis\data\qis.mdb"
conn.Open
Sql_str="SELECT  * FROM srm_list "
set rs=server.createobject("adodb.recordset")
rs.open Sql_str,conn,1,1
rs2=rs.getrows
%>
<script>
var arrList = new Array();
<%for i=0 to rs.recordcount%>
arrList[<%=i%>] = '<%=rs2(11,1)%>'
alert (arrList[<%=i%>])
<%next%>
</script>现在遇到的问题是:
我只要一把'<%=rs2(11,1)%>'变更为'<%=rs2(11,i)%>',代码就运行不了
而且只有在<%for i=0 to 1%>的时候'<%=rs2(11,i)%>'代码就可以运行
现在是想不清楚,高手指点一下啊

解决方案 »

  1.   

    rs.recordcount没有问题,有100多
    关键是就算我不用rs.recordcount,将它改成<%for i=1 to 2%>也还行
    只要大于1就还行,真是奇怪
      

  2.   

    arrList[<%=i%>] = '<%=rs2(11,1)%>' 这一句为什么加引号,
    你<script> .... </script>内是VB吗
      

  3.   

    应该是<%for i=0 to rs.recordcount-1%>试想一下,如果你的数据有两行,那么就应该执行两次循环,此时rs.recordcount为2
    而如果是<%for i=0 to rs.recordcount%>,那么将有 i=0,i=1,i=2 共三次循环,当然出错
      

  4.   


    是这样的:
    用rs.recordcount-1我也试过也是不行
    而且我用response.write rs.reocordcount可以得是:136
    现在关键不是这个rs.reocordcount
    而是只要i>1这段代码就不能运行
    奇怪的地方就在这里
      

  5.   

    突然发现,可能是你的rs用法可能有问题
    为什么不用rs.next()来遍历,用rs("字段名")来取值这样的方式呢?