请问:
   在ADO中如何对表中的记录进行排序,不用SQL语言,记录集中有什么属性可达到这个目的,格式是怎样的

解决方案 »

  1.   

    select * from tabel1 order by id asc
    不挺好的吗?
      

  2.   

    CString strSort;
    strSort = "Field1 DESC ";
    pRecordset->Sort = (_variant_t)(_bstr_t)strSort;
    也可能是
    pRecordset->Sort = (_bstr_t)(LPCTSTR)strSort;
    很好用的
    如果要对多个字段排序
    就可以
    strSort = "Field1,Field2,Field3 ASC";
      

  3.   

    如果使用order by的话,得到的纪录集是无法Update的,
    所以除非你只读数据库,否则的话最好使用Sortm_pRecordset->CursorLocation=adUseClient;
    hr=m_pRecordset->Open(bstrQuery,_variant_t((IDispatch *)m_pConnection,true), adOpenForwardOnly,adLockOptimistic,adCmdText);
    m_pRecordset->Sort="Sort = "姓名 DESC, 年龄 ASC";降序的话要加DESC,升序的话ASC可以省略
      

  4.   

    最后一句代码是
    m_pRecordset->Sort="姓名 DESC, 年龄 ASC";
      

  5.   

    如果你实在不喜欢用order by,那么你读回数据后自己排序好了
      

  6.   

    用Sql了,你都读了,为什么不呢,不过ADO里面好像是有的