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

功能无法读出,请教各位高人!
<%
set   rs=server.createobject( "adodb.recordset ")
sql= "select   top   5   *   from   SMT_cp   where   SMT_key3   =   1   order   by   SMT_date   desc "
rs.open   sql,conn,1,1

imgUrl=rs( "SMT_pic ")
imgtext=rs( "SMT_cpname ")
imgLink=rs( "SMT_id ")

dim   n
for   n   =   1   to   5

imgUrl(n)=trim(imgUrl(n))
imgtext(n)=trim(imgtext(n))
imgLink(n)=trim(imgLink(n))

response.write   imgUrl(n)
Next
rs.close
%>
response.write   无法读出!

------解决方案--------------------
<%
set rs=server.createobject( "adodb.recordset ")
sql= "select top 5 * from SMT_cp where SMT_key3 = 1 order by SMT_date desc "
rs.open sql,conn,1,1

n = 0
Do While Not rs.eof

imgUrl(n)=trim(rs( "SMT_pic "))
imgtext(n)=trim(rs( "SMT_cpname "))
imgLink(n)=trim(rs( "SMT_id "))

response.write imgUrl(n)

n = n + 1
rs.movenext
loop
rs.close
%>
------解决方案--------------------
set rs=server.createobject( "adodb.recordset ")
sql= "select top 5 * from SMT_cp where SMT_key3 = 1 order by SMT_date desc "
rs.open sql,conn,1,1
do while not rs.eof
imgUrl=rs( "SMT_pic ")
imgtext=rs( "SMT_cpname ")
imgLink=rs( "SMT_id ")


imgUrl(n)=trim(imgUrl(n))
imgtext(n)=trim(imgtext(n))
imgLink(n)=trim(imgLink(n))

response.write imgUrl(n)
rs.movenext
loop
rs.close
------解决方案--------------------
imgUrl(n)=trim(imgUrl(n))
imgtext(n)=trim(imgtext(n))
imgLink(n)=trim(imgLink(n))
楼主的这个应该是数组吧。你得定义一下数组才行啊
------解决方案--------------------
感觉你的代码有问题

你想打印什么数据?

想从数据库中循环读出数据?
------解决方案--------------------
不用定义了

rs.Open 语句之后直接写:

dim arrData

if not rs.eof then

arrData = rs.getRows(-1)

else

arrData = null

end if

这样如果rs不为空得到的就是一个二维数组~~