Results 1 to 2 of 2

Thread: How do i retrieve the table names on my Access database?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    1

    Post How do i retrieve the table names on my Access database?

    im using an mdb database (Microsoft Access)
    i made my oledbconnection thru code:
    Dim cnn As OleDbConnection
    Dim strConn As String
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
    "Data Source=C:\mydata.mdb;" + _
    "Mode=Share Deny None"
    cnn = New OleDbConnection(strConn)

    dragging the tables from the server explorer into my form is not appropriate for my application, because additional tables might be added to the database in the future.
    what i want is to display all the table names inside "mydata.mdb" on myListBox control.
    do i need additional objects such as oledbcommand,...
    pls fill up the missing code. thanks a lot!

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Funnily enough, there is a table in Access that hold all the table names, you just cant see it.

    Go into access, Goto Tools, Options, View, and select hidden and system objects. You will then see a table called MSysObjects.
    Im sure you can use this table to get a list of all the tables in the system.


    Heres a SQL statement you can run from your program to get a recordset of all the tables

    SELECT MSysObjects.Name
    FROM MSysObjects
    WHERE (((MSysObjects.Type)=1) AND ((MSysObjects.Flags)=0));


    Have fun

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