Finding all tables from schema information

  • Thread starter Thread starter Max
  • Start date Start date
M

Max

Hi there!

Can anyone please answer the following question?

I'm trying to get a list of tables, which has to work for different
databases.
A user chooses a database, and then this list is showed. This works.
My problem is that in case of an Access-database all tables are showed
(because the second restriction argument is set to nothing), and in
case of Oracle i just want to show the tables that are available to
the user, and NOT all tables.

Private Sub GetAllTableNames()
Dim conn As OleDbConnection
conn = New OleDbConnection(gstrNSConn)
conn.ConnectionString = gstrNSConn
conn.Open()

'MS Access
dtColumns = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New
Object() {Nothing, Nothing, Nothing, "TABLE"})

'Oracle
'dtColumns = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New
Object(){Nothing, mstrUserID, Nothing, "TABLE"})
End Sub

Can anyone tell me how to solve this generically (some form of
detection?)
Thanks in advance!!
Max
 
Hi Max,
As an alternative, you can query the database itself
For Oracle, you can type SELECT * FROM USER_TABLES
For Sql-Server you have a stored procedure sp_tables (or something similar)
Selim
 
Back
Top