TQuery and TTable

From: Stark (franco.jommi_at_tin.it)
Date: 09/28/04


Date: Tue, 28 Sep 2004 19:03:39 GMT

I am trying to learn to use TQuery rather than TTable, but I am finding
difficult to do things with TQueries that I did rather easily with TTables.
For example, showing my dataset in a DBGrid and changing sort sequence
according to specific columns was easy with TTables:

procedure TMainForm.DBGridBooksTitleButtonClick(Sender: TObject;
AFieldName: String);
begin
   if aFieldName='Author' then
      BiblioDM.BooksTable.IndexName:= 'AUTX';
   if aFieldName='Editor' then
      BiblioDM.BooksTable.IndexName:= 'EDIX';
etc.
....

How would I do the same thing with TQueries ?

Also, it seems to me that is more efficient to show directly a TTable in a
DBGrid (via its Datasource, of course), while showing the same dataset with
a TQuery implies a "Select" statement and therefore more processing time.
Can anyone explain why the use of TTables is discouraged then ? Or did I
misunderstand ?


Quantcast