ASP显示数据库文章

来源:百度知道 编辑:UC知道 时间:2024/06/23 01:00:14
<%id=trim(request("nid"))
if id="" then id=15
set rs=conn.execute("select * from news where cid="&id)
dim i
i=0
title=rsnews("ncontent")
if rs.eof then response.write "<tr><td><font color='red'>暂无信息</font></td></tr>"
do while not rs.eof
if rs.eof then exit do
%>

<tr>
<td align="center"><a href="view_new.asp?id=<%=rs("nid")%>&cid=<%=rs("cid")%>" target="_blank" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image<%=i%>','','<%=rs("tuurl2")%>',1)"><img src="<%=rs("tuurl1")%>" name="Image<%=i%>" width="417" height="65" border="0"></a></td>
</tr>

title=rsnews("ncontent")
if rs.eof then response.write "<tr><td><font color='red'>暂无信息</font></td></tr>"
改成
title=rs("ncontent")
if rs.eof then response.write "<tr><td><font color='red'>暂无信息</font></td></tr>"
else response.write "<tr><td><font color='red'>"& title &"</font></td></tr>" end if

直接读取不就可以了吗?
不知道是什么意思
另外有个地方看不懂
title=rsnews("ncontent")
不知道你的rsnews是什么?你用的全部是rs

要显示ntext的内容,就不能用 set rs=conn.execute的方法了
应该用:set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1

set rs=conn.execute的方法有很多限制,比如不能读取ntext内容,也不能获取rs.recordcount的内容等等,自己试试吧