Page 1 of 1

Get the Table name?

Posted: Thu 12 Jul 2007 14:36
by shsit
Hi,

is there a way to get the table name of my query or must I extract it from the SQL.Text property myself?

Thx.

Posted: Fri 13 Jul 2007 15:29
by Antaeus
Yes, this one of the ways.
Another way is to check to what table belongs a field in your dataset. It may look like this:

Code: Select all

uses
 MyClasses;
...
var
 FieldDesc: TMySQLFieldDesc;
...
  FieldDesc := TMySQLFieldDesc(MyQuery1.GetFieldDesc(MyQuery1.FieldByName('deptno')));
  ShowMessage(FieldDesc.TableInfo.TableName);
Note, some fields may not belong to a table. This concerns lookup and calculated fields, fields that are the result of a function, etc.