Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting table names and field names from database 1

Status
Not open for further replies.

peekay

Programmer
Oct 11, 1999
324
ZA
I need to know which tables are in an Access database. The closest I can get is :

Dim schemaTable As DataTable = Cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})

I do not know however how to extract the table names from this. I also need to know which fields (columns) are in a certain table once I have its name.

Thanks

PK Odendaal
 
I have been able to extract the table names. Can somebody please assist me with extraction of the field names.

Thanks


PK Odendaal
 
You could try Describe tablename, or Desc tablename. Not sure if either of those work in Access though. You might want to check the Access forums.

-Rick

----------------------
 
Is this a .NET question? Because you also posted this question in Visual Basic(Microsoft) Databases, which is usually a VB6 forum.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
This is a VB.NET and Access question.
ThatRickGuy - can you please elaborate on the SQL
Thanks

PK Odendaal
 
What's the to elaborate on?

Describe [tablename]

or

Desc [tablename]

You may be able to do it through VB.Net also, by creating a datatable from the access table and then loop through the columns to get their names.

-Rick

----------------------
 
You can also do a SELECT with a WHERE clause that will cause 0 rows to be returned:
Code:
SELECT *
FROM tbl_whatsitsname
WHERE 1=0
You can then go through the Columns collection in your DataTable to find out about all the columns.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
chiph

Thanks for the help - I will take this route, but I still need some assistance if you please.
How do I set up the datatable ?
Must I first set up a dataadapter and fill the dataset or can I directly do a sql query and fill the datatable. If you have some code I will appreciate.
Thanks

PK Odendaal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top