CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Posts
    14

    Tables in a database

    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


  2. #2
    Join Date
    Apr 2001
    Posts
    14

    Re: Tables in a database

    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


  3. #3
    Join Date
    Aug 2000
    Location
    KY
    Posts
    766

    Re: Tables in a database

    You can also reference the ADO 2.1 Ext for Security. It provides access to permissions, tables, views, primary keys and constraints.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured