CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: MSACCESS

  1. #1
    Join Date
    Jun 2000
    Posts
    104

    MSACCESS

    How can i generate a list of all the tables of a MSAccess database that i am selecting through a common dialogbox?Thanks in advance.


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: MSACCESS

    One way of doing this is to execute SQl

    sSQL = "Select Name from MSysObjects where Type = 1"

    rs.OPen sSQl, adOpenDynamic, adLockOptimistic

    and then you can enter this for example to a listbox

    do while not rs.eof
    lst.AddItem rs!Name
    rs.movenext
    Loop

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: MSACCESS

    Using ADOX

    Sub ListTables()

    Dim cat As New ADOX.Catalog
    Dim tbl As ADOX.Table

    'References : Microsoft ADO Ext 2.1 or DDL and Security

    ' Open the catalog
    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\nwind.mdb;"

    ' Loop through the tables in the database and print their name
    For Each tbl In cat.Tables
    If tbl.Type <> "VIEW" Then Debug.Print tbl.Name
    'not to see system tables If Left$(tbl.Name, 4) <> "MSys" Then Debug.Print tbl.Name

    Next

    End Sub

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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