How do I get the TableName of a DataSet?
I tried this:
var
Tblname: string;
begin
Tblname := DBGrid1.DataSource.DataSet.TableName;
//it is not working
//DataSet.TableName is protected
end;
How do I get the TableName of a DataSet?
I tried this:
var
Tblname: string;
begin
Tblname := DBGrid1.DataSource.DataSet.TableName;
//it is not working
//DataSet.TableName is protected
end;
Copyright © 2021 Jogjafile Inc.
Using RTTI it is possible to get the value for any property. The example below returns the value of the
TableNameproperty, provided there is one. I have verified that the code works in a small project.The main benefit would be that it works on any
TDatasetderived class that has aTableNameproperty. (egTTable, but alsoTSQLTableorTFDTable)Or an alternate solution using the old-style typinfo module (tested on RS 10.3, but I expect it to work on D7 as well)