关于一个ASP循环查询问题

[复制链接]
查看11 | 回复2 | 2009-2-19 09:04:27 | 显示全部楼层 |阅读模式
Set rst = Server.CreateObject("ADODB.RecordSet")
sqlt="select * from wtsp order by id desc"
rst.Open sqlt,conn,3,3
do while not rst.eof

sql="select * from mainall where shangpinmingcheng='"&rst("shangpinmingcheng")&"' order by id desc"
Set rs = Server.CreateObject("ADODB.RecordSet")

rs.Open sql,conn,3,3
rst.movenext
loop
rst.close
set rst=nothing
以上代码只能查询 wtsp 表的第一条记录
请问怎么修改才是完美的呢?

回复

使用道具 举报

千问 | 2009-2-19 09:04:27 | 显示全部楼层
后面那句声明游标放错位置了 因为同一个游标在没有释放的时候不能重新声明 应该这样写 Set rst = Server.CreateObject("ADODB.RecordSet") sqlt="select * from wtsp order by id desc" rst.Open sqlt,conn,3,3 Set rs = Server.CreateObject("ADODB.RecordSet") '声明游标 do while not rst.eof sql="select * from mainall where shangpinmingcheng='"&rst("shangpinmingcheng")&"...
回复

使用道具 举报

千问 | 2009-2-19 09:04:27 | 显示全部楼层
do while not rst.eof 改成do while rst.eof...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行