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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to know what Tables include a DataBase in Access 1

Status
Not open for further replies.

plopez

Technical User
Apr 2, 2002
66
CL
Hi,my question is how can I know how many Tables are into an Access Data Base and the name of all them.

When I have that,I need to populate each Table in a DataGrid or a MSFlexgrid in my App.

I really appreciate ur help.

Thanks


 
Run this SQL
Code:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE MSysObjects.Type = 1

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Another method:

Dim Conn As OleDbConnection = New OleDbConnection("<your connection string here>")
Conn.Open()

Dim dt As DataTable

dt = Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})

'display in a DataGrid
DataGrid1.DataSource = dt

Conn.Close()


As a side note, you can also use this method to list any queries in the database. Just change "TABLE" to "VIEW":

dt = Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "[red]VIEW[/red]"})

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top