我用下面的代码来计算查询到的记录,现在出现了一个好奇怪的问题,当查询到的记录少8条(包括8条)能够显示出查询到的记录数但数据量在大于时rc的值为-1,我在别的地方这么用不会出现这种问题请各位大虾帮我看看就什么问题.
procedure TfrmResponse.QueryMobileResponseAfterOpen(DataSet: TDataSet);
var
 rc : Integer;  //计算查询到的记录数
begin  rc := QueryMobileResponse.RecordCount;
  //记录查询到的数据
  If rc < 0 then rc := 0;  gbInfo.Caption := gbInfo.Caption + ':' +
    inttostr(rc);end;

解决方案 »

  1.   

    先执行查询语句,再
    用query1adoquery1.RecordCount看一下
      

  2.   

    从来不用RecordCount,靠不住Note: Use RecordCount with care, because record counting can be a costly 
             …………………………………
    operation, especially for SQL queries that return large result sets. Generally, an application should only use RecordCount with Paradox and dBASE tables.Note: The number of rows indicated might be less than the total number of 
                                          …………………………       
    rows in a table. This can happen when the rows retrieved as a recordset for a dataset component are a conditional subset of the table.
      

  3.   

    Select count(*) 
    From yourTable
    Where 条件