Click to See Complete Forum and Search --> : Tables in a database
briana02
April 30th, 2001, 08:15 AM
Is there a method or property that will allow me to retrieve a list of tables in a database? I'm creating an app using ADO that allows the user to update a selected database. When the user selects with db he wishes to work with, I would like to present a combo box with list of available tables. Is there any way to obtain that list programmatically?
Thanks
Brian
briana02
April 30th, 2001, 08:41 AM
Okay guys, I figured it out - but I thought I would go ahead and post the solution for those who are interested. It comes from MSDN Library.
Sub ADOListTables2()
Dim cnn As New ADODB.Connection
Dim rst As ADODB.Recordset
' Open the connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=.\NorthWind.mdb;"
' Open the tables schema rowset
Set rst = cnn.OpenSchema(adSchemaTables)
' Loop through the results and print
' the names in the debug window
Do Until rst.EOF
If rst.Fields("TABLE_TYPE") <> "VIEW" Then
Debug.Print rst.Fields("TABLE_NAME")
End If
rst.MoveNext
Loop
End Sub
dfwade
April 30th, 2001, 08:48 AM
You can also reference the ADO 2.1 Ext for Security. It provides access to permissions, tables, views, primary keys and constraints.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.