asp 循环错误
下面的代码,有错误:提示对象关闭时,不允许操作,而且只生成了一个页面index_9.html错在哪,请啊手指教。谢谢。setrs=Server.CreateObject(...
下面的代码,有错误:
提示对象关闭时,不允许操作,而且只生成了一个页面 index_9.html
错在哪,请啊手指教。谢谢。
set rs=Server.CreateObject("Adodb.Recordset")
Sql="select * from news where parent=0 order by Time desc"
rs.open sql,conn,1,1
AllCount=Rs.RecordCount
indexPageSize=40
Pages=Fix(AllCount/indexPageSize)
If Pages*indexPageSize<AllCount Then Pages=Pages+1
function countimg()
for ii=1 to indexPageSize
if rs.eof then
exit for
end if
countimg=countimg & "ok "&vbcrlf
rs.movenext
next
rs.close
set rs=Server.CreateObject("Adodb.Recordset")
Sql="Select Top 8 * From news order by Time desc"
rs.open sql,conn,1,1
For i=1 To Rs.RecordCount
countimg=countimg&"new"&vbcrlf
Rs.MoveNext
Next
rs.close
end function
for i=1 to pages
classurl=countimg()
if i=1 then
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath&"index.html",2
stm.Close
else
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath&"index_"&i&".html",2
stm.Close
end if
Next 展开
提示对象关闭时,不允许操作,而且只生成了一个页面 index_9.html
错在哪,请啊手指教。谢谢。
set rs=Server.CreateObject("Adodb.Recordset")
Sql="select * from news where parent=0 order by Time desc"
rs.open sql,conn,1,1
AllCount=Rs.RecordCount
indexPageSize=40
Pages=Fix(AllCount/indexPageSize)
If Pages*indexPageSize<AllCount Then Pages=Pages+1
function countimg()
for ii=1 to indexPageSize
if rs.eof then
exit for
end if
countimg=countimg & "ok "&vbcrlf
rs.movenext
next
rs.close
set rs=Server.CreateObject("Adodb.Recordset")
Sql="Select Top 8 * From news order by Time desc"
rs.open sql,conn,1,1
For i=1 To Rs.RecordCount
countimg=countimg&"new"&vbcrlf
Rs.MoveNext
Next
rs.close
end function
for i=1 to pages
classurl=countimg()
if i=1 then
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath&"index.html",2
stm.Close
else
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath&"index_"&i&".html",2
stm.Close
end if
Next 展开
展开全部
function countimg()
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from news where parent=0 order by Time desc"
rs.open sql,conn,1,1
for ii=1 to indexPageSize
if rs.eof then
exit for
end if
countimg=countimg & "ok " & vbcrlf
rs.movenext
next
rs.close
Sql="Select Top 8 * From news order by Time desc"
rs.open sql,conn,1,1
For ii=1 To rs.RecordCount
countimg=countimg & "new" & vbcrlf
rs.MoveNext
Next
rs.close
set rs=nothing
end function
set rs=Server.CreateObject("Adodb.Recordset")
Sql="select * from news where parent=0 order by Time desc"
rs.open sql,conn,1,1
AllCount=rs.RecordCount
rs.close
set rs=nothing
indexPageSize=40
pages=Fix(AllCount/indexPageSize)
If pages*indexPageSize<AllCount Then pages=pages+1
for i=1 to pages
classurl=countimg()
if i=1 then
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath & "index.html",2
stm.Close
else
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath & "index_" & i & ".html",2
stm.Close
end if
Next
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from news where parent=0 order by Time desc"
rs.open sql,conn,1,1
for ii=1 to indexPageSize
if rs.eof then
exit for
end if
countimg=countimg & "ok " & vbcrlf
rs.movenext
next
rs.close
Sql="Select Top 8 * From news order by Time desc"
rs.open sql,conn,1,1
For ii=1 To rs.RecordCount
countimg=countimg & "new" & vbcrlf
rs.MoveNext
Next
rs.close
set rs=nothing
end function
set rs=Server.CreateObject("Adodb.Recordset")
Sql="select * from news where parent=0 order by Time desc"
rs.open sql,conn,1,1
AllCount=rs.RecordCount
rs.close
set rs=nothing
indexPageSize=40
pages=Fix(AllCount/indexPageSize)
If pages*indexPageSize<AllCount Then pages=pages+1
for i=1 to pages
classurl=countimg()
if i=1 then
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath & "index.html",2
stm.Close
else
stm.open
stm.WriteText classurl
stm.SaveToFile parentPath & "index_" & i & ".html",2
stm.Close
end if
Next
更多追问追答
追问
谢谢。实际运行还是有问题:
生成的个每一页内容都完全一样。
这一句:countimg=countimg & "ok " & vbcrlf
改成如下后:
countimg=countimg & ""&Rs("id")&" " & vbcrlf
实际上生成后每页的内容都是一样的。
可见每页的内容并没有循环。
请高手帮忙。
追答
修改后的代码超出字数限制了,想发到你的私信,发现你是匿名的,咋办?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询