Get the Table name?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
shsit
Posts: 21
Joined: Thu 05 Oct 2006 11:41

Get the Table name?

Post by shsit » Thu 12 Jul 2007 14:36

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.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 13 Jul 2007 15:29

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.

Post Reply