OleDbDataAdapter da=new OleDbDataAdapter("select top 8 NewsOrder,ItemID,CreatedDate,Title from News where (IsHot=true and IsCheck=true ) ",myConnection);C#操作access 如上的的话取出来的数据确实是8条了如果sql语句加上ORDER BY CreatedDate排序 如下
然后取出啦的数据条数就不对了 多于8条了
OleDbDataAdapter da=new OleDbDataAdapter("select top 8 NewsOrder,ItemID,CreatedDate,Title from News where (IsHot=true and IsCheck=true ) ORDER BY CreatedDate",myConnection);

解决方案 »

  1.   

    select top 8 NewsOrder,ItemID,CreatedDate,Title from News where IsHot=true and IsCheck=true  ORDER BY CreatedDate
      

  2.   

    是在access中了 我试过了还是这样了 有谁知道这是为什么啊?还是找不出原因了现在用下面的这种方式解决的
    select top 8 * from (select NewsOrder,ItemID,CreatedDate,Title from News  where (IsHot=true and IsCheck=true ) ORDER BY CreatedDate) 
      

  3.   

    索引、主键 条件  检查检查。#region 广告开始  CSDN小助手 V2.5,更快、更爽、更方便的浏览CSDN论坛!
      界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
      下载:http://szlawbook.com/csdnv2***
      我们每回答一个问题,
      就谋杀了提问者一个思考的机会,
      而这个思考的机会可能让他获得10倍的知识,
      所以,我们不下地狱谁下地狱?
    ***#endregion
      

  4.   

    select distinct top 8 * from (select NewsOrder,ItemID,CreatedDate,Title from News  where (IsHot=true and IsCheck=true ) ORDER BY CreatedDate) 
    看看行不行。
      

  5.   

    CreatedDate????
    你这应该是创建日期吧
    因为CreatedDate可能相同的,如果你用select top 1 from 表 order by createDate
    因为CreatedDate列可能有很多相同日期的,也就是值相同,这时候会把所有相同的值都检索出来的,
    select distinct好像是检索不同的记录吧,
    最好的办法是创建一个id字段,设置为关键字,主键,让它自动加一,这样就不会有相同的id记录了
    然后用id来检索