我用CDaoRecordset 打开一个记录集,但是第一次用GetRecordCount 的时候都返回的是1,为什么?

解决方案 »

  1.   

    如果你想获得记录集中记录的个数,首先用MoveLast 或者 FindLast ,再调用该函数。注意GetRecordCount返回的是: the number of records have been accessed in a recordset object.
    具体见MSDN
      

  2.   

    同意楼上的
    最好用select count(*) from table1 来取得记录数
      

  3.   

    是的,具体:
    (1)先打开记录集,如if(!MyRecorderSet.IsOpen())MyRecorderSet.Open();
    (2)MyRecorderSet.MoveLast();
    (3)int RecordNumber=caobase.GetRecordCount()。