标题:查询语句有错,请帮助
只看楼主
zhuzhanjun
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2008-5-3
结帖率:100%
 问题点数:0 回复次数:18 
查询语句有错,请帮助
select top 5 * from content order by infotime desc


以上的语句不是按照时间来排序最新五条数据的吗?
怎么我显示出7条数据。好奇怪哦。。

求高手帮助

1.jpg (14.5 KB)
搜索更多相关主题的帖子: 语句 查询 order 数据 content 
2008-06-06 09:36
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
得分:0 
do while ... loop循环?
2008-06-06 09:37
zhuzhanjun
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2008-5-3
得分:0 
代码如上:


<%    
                dim sqlBL,rsBL
                sqlbl="select top 5 * from content order by infotime desc"
                set rsbl=server.CreateObject("adodb.recordset")
                rsbl.open sqlbl,conn,1,3
            %>
            <TABLE cellSpacing=0 cellPadding=3 width="99%" align=center border=0>
              <TBODY>
              
                <tr><td height="5"></td></tr>
                <%
                    if not rsbl.eof then
                    do while not rsbl.eof
                %>
                  <TR>
                <TD width="29%"><SPAN  class=red2>[ <%=rsbl("BigClassName")%> ]</SPAN></TD>
                <TD width="70%">
                    <A href="blog/blog_list.asp?id=<%=rsbl("id")%>"><%=left(rsbl("title"),14)%>...</A>
                </TD>
                 </TR>
                <%
                    rsbl.movenext
                    loop
                    rsbl.close
                    set rsbl=nothing
                    end if                    
                %>
2008-06-06 09:59
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
得分:0 
用for循环看看?
for i = 1 to rs.recordcount
if rs.eof then exit for
  ...
rs.movenext
next
2008-06-06 10:10
zhuzhanjun
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2008-5-3
得分:0 
还是显示七条啊
2008-06-06 10:24
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
得分:0 
Response.Write rs.recordcount
看看一共是多少条记录啊
这种简单的测试要学着做的
2008-06-06 10:26
cnly
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-5-26
得分:0 
<%   
                dim sqlBL,rsBL
                sqlbl="select top 5 * from content order by infotime desc"
                set rsbl=server.CreateObject("adodb.recordset")
                rsbl.open sqlbl,conn,1,3
            %>
            <TABLE cellSpacing=0 cellPadding=3 width="99%" align=center border=0>
              <TBODY>
              
                <tr><td height="5"></td></tr>
                <%
                    if rsbl.eof then
                         Response.write("没有记录")
                    else
                    do while not rsbl.eof
                %>
                  <TR>
                <TD width="29%"><SPAN  class=red2>[ <%=rsbl("BigClassName")%> ]</SPAN></TD>
                <TD width="70%">
                    <A href="blog/blog_list.asp?id=<%=rsbl("id")%>"><%=left(rsbl("title"),14)%>...</A>
                </TD>
                 </TR>
                <%
                    rsbl.movenext
                    loop
                    rsbl.close
                    set rsbl=nothing
                    end if                    
                %>
2008-06-06 10:26
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
得分:0 
只读不需要rsbl.open sqlbl,conn,1,3  rsbl.open sqlbl,conn,1,1就可以了
Response.Write sqlbl
Response.End()
输出的SQLBL结果放入数据库查询分析一下
2008-06-06 10:28
zhuzhanjun
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2008-5-3
得分:0 
Response.Write ("abc::::::::::::::"+rsbl.recordcount)
    response.End()


什么都没有显示啊
2008-06-06 10:40
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
得分:0 
Response.Write sqlbl
Response.End()
输出的SQLBL结果放入数据库查询分析一下
2008-06-06 10:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-217889-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.026235 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved