Click here to Skip to main content
15,896,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been looking for a way to take all relevant tables in Access and have them show up in combobox.

I tried using this:
 Dim AccessConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" Records.accdb";")
AccessConnection.Open()
Dim adt As DataTable '= AccessConnection.GetSchema("Tables")
DataGridView2.DataSource = adt
AccessConnection.Close


The problem is this brings up all tables including hidden tables. I just want the relevant tables that are associated to my database.

What I have tried:

I tried to use a connection string:
Dim Accessda = New OleDbDataAdapter("SELECT MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Type)=1 Or (MSysObjects.Type)=6) AND ((Left([Name],4))<>'MSys')) ORDER BY MSysObjects.Name;", AccessConnection)


but I kept getting an error.

If there is a better way to get just the tables of the database that would be great
Posted
Updated 27-Nov-17 19:43pm
Comments
ZurdoDev 27-Nov-17 15:52pm    
What was the error?

1 solution

Use this query -

SQL
SELECT * FROM MSysObjects  WHERE Type=1 AND Flags=0;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900