Board index » delphi » Get list of tables/views in SQL Database

Get list of tables/views in SQL Database

I would like to use a view to get a list of all the tables and views in a
database Here  is the view I created.

create view ALL_TABLES_VIEWS as
select TABLE_NAME from INFORMATION_SCHEMA.TABLES
go

When I try to access the data using a TQuery like below it tells me that
column does not exist.

Query1.FieldByName('TABLE_NAME').AsString)

I'm using SQL Server 7.0 and D5.  Any help is greatly appreciated.

Bob

 

Re:Get list of tables/views in SQL Database


Try right clicking on the Query1 object and making the field names
persistent...

Juan

Quote
Bob wrote:

> I would like to use a view to get a list of all the tables and views in a
> database Here  is the view I created.

> create view ALL_TABLES_VIEWS as
> select TABLE_NAME from INFORMATION_SCHEMA.TABLES
> go

> When I try to access the data using a TQuery like below it tells me that
> column does not exist.

> Query1.FieldByName('TABLE_NAME').AsString)

> I'm using SQL Server 7.0 and D5.  Any help is greatly appreciated.

> Bob

Re:Get list of tables/views in SQL Database


1. your example works fine here
2. you don't need a view for that simple query
3. dunno what you wanna achieve but you might also want to have a look at
the BDE help files, i.e. DbiGetFieldDescs

--Joe

Re:Get list of tables/views in SQL Database


Juan, I tried to right click and there weren't any fields in the editor.

Joe, I cannot get it to work here.  I am using an odbc entry in my database
component.
Could that be the probolem?

Thanks for your help.

Re:Get list of tables/views in SQL Database


Did you click on Add or Add All to bring the field names into the
listbox?
Quote
Bob wrote:

> Juan, I tried to right click and there weren't any fields in the editor.

> Joe, I cannot get it to work here.  I am using an odbc entry in my database
> component.
> Could that be the probolem?

> Thanks for your help.

Other Threads