AdoQuery.SQL.Add('select count(*) from Table);

AdoQuery.SQL.Add('select count(*) from Table);
Where do I find the result (without using DBEdit connected to the DataSource & datafield=Expr1000)?

Comments

  1. var
      iCount: integer;
    begin
      AdoQuery.SQL.Add('select count(*) from Table);
      try
        AdoQuery.Open;
        iCount := AdoQuery.Fields[0].AsInteger;
        AdoQuery.Close;
      except
        iCount := -1;
      end;
    end;

    ReplyDelete
  2. or the easy way:
    ...
    AdoQuery.SQL.Add('select * from table');
    AdoQuery.Open;
    icount:=AdoQuery.RecordCount;
    AdoQuery.Close;
    ...

    ReplyDelete
  3. Heinz Toskano Yeah and the easy way then transfers the bazillion records over the net into your ADOTable...

    ReplyDelete
  4. Stefan Glienke using Recordcount is a bit lame ; I propose 

    While not AdoQuery.Eof do inc(icount);

    ReplyDelete
  5. Stefan Glienke You're right, maybe not the best way, but it's easier and works... and will waste a lot of resources and time.
    Seriously Olivier SCHWAB? ;-)

    ReplyDelete
  6. Sorry Heinz Toskano , bad monday at work , so my tongue is a little bit sarcastic ;)

    ReplyDelete
  7. Olivier SCHWAB np man, we all have a bad day, sometimes, specially mondays, mine is just about to begin ;-)

    ReplyDelete
  8. Abderak open the dataset and get Fields[0].value

    ReplyDelete

Post a Comment