Board index » delphi » Run time list of table names in a database

Run time list of table names in a database

I am in the process of working out how to write some
Delphi code that makes it possible to examine the
structure of a database at run time and create the
SQL "create table" and "create index" statements that
would create that database structure.  I have worked
out most aspects of the problem, but there is one
remaining question:

In the object inspector for a TTable, after the
DatabaseName property is provided, a popup list for
the TableName property offers a list of table names
that exist in that database.  How can you get your
hands on that list of table names in Delphi?

Any other suggestions concerning the overall task
would be appreciated.

Thanks for your help!

Dave Eland
davel...@oru.edu

 

Re:Run time list of table names in a database


Look at TSession's GetTableNames.  This will return all the table names for a
particular database.  Depending on the backend you might want to just query the
backend itself if you want to filter out system tables, etc, but GetTableNames
is a good starting point in most cases.

Quote
Dave Eland wrote:

> I am in the process of working out how to write some
> Delphi code that makes it possible to examine the
> structure of a database at run time and create the
> SQL "create table" and "create index" statements that
> would create that database structure.  I have worked
> out most aspects of the problem, but there is one
> remaining question:

> In the object inspector for a TTable, after the
> DatabaseName property is provided, a popup list for
> the TableName property offers a list of table names
> that exist in that database.  How can you get your
> hands on that list of table names in Delphi?

> Any other suggestions concerning the overall task
> would be appreciated.

> Thanks for your help!

> Dave Eland
> davel...@oru.edu

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Live never to be ashamed if anything you do or say is published around the world
- even if what is published is not true.    (R Bach)

Re:Run time list of table names in a database


Quote
>Dave Eland wrote:

> In the object inspector for a TTable, after the
> DatabaseName property is provided, a popup list for
> the TableName property offers a list of table names
> that exist in that database.  How can you get your
> hands on that list of table names in Delphi?

Just cut the words 'your hands on that list of' from
your last sentence <g>:
Session.GetTableNames
________
Andreas

Re:Run time list of table names in a database


Thanks for your response.  It works!

Dave Eland
davel...@oru.edu

Other Threads