Click to See Complete Forum and Search --> : Listing Tables and their fields


v_vijay
November 11th, 1999, 09:38 PM
Hi!

I want to get a listing of tables and their fields given a DSN.
I will be using ADO library
I have got a listing of tables using OpenSchema method of connection.
But i don't know how to get a listing of field names in a table.
Present i am doing Select * from table_name for each table
But this will harm the performance and maytake a long time in case of large
number of tables
Can someone suggest a differnt method
I want the method to be database independent

Thanx and Regards
Vijay

Lothar Haensler
November 12th, 1999, 02:00 AM
this sample get column information for a specific table


Dim cnn1 as ADODB.Connection

Dim rstSchema as ADODB.Recordset

set cnn1 = DataEnvironment1.Connection1

cnn1.Open

set rstSchema = cnn1.OpenSchema(adSchemaColumns, Array("mydb", "dbo", "mytable"))

Dim i as Integer

Do Until rstSchema.EOF

for i = 0 to rstSchema.Fields.Count - 1

List1.AddItem rstSchema.Fields(i).Name & " = " & rstSchema.Fields(i).Value

next i

List1.AddItem "-------------------------------"

rstSchema.MoveNext

Loop

rstSchema.Close

cnn1.Close