Results 1 to 5 of 5

Thread: Displaying all tables

  1. #1
    Join Date
    Sep 2006
    Posts
    2

    Displaying all tables

    Can anyone help.

    Im trying to display all tables in a MS Access database through an application i have created in C#. What is the command that displays all tables. I know in MySQL "SHOW TABLES" is the command but i need the MS ACCESS equivalent.

    The command is then used as an argument for an OdbcCommand oject.

    Any help would be much appreciated.

    Thanks

  2. #2
    Join Date
    Sep 2005
    Posts
    168
    --the following query works for MSAccess 2003

    SELECT Name FROM MSysObjects WHERE type=1

    --Note: system tables are also returned.

    --HTH--

  3. #3
    Join Date
    Sep 2006
    Posts
    2
    hmm. Im trying to read the tables through c#.

    Yeh but there are no read permissions with msysobjects.

    This is the error message im getting.

    Message: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'MSysObjects'.

  4. #4
    Join Date
    May 2006
    Posts
    407
    do you have the Access Application object model available to you in C#? I don't know C# at all, but if you have the VBA code, can you then actually convert that to C# and operate on the Access Application object with C#?
    For example, to get all the tables, but not using MSysObjects, you would use the object TableDefs. TableDefs contains all the individual TableDef objects of all the tables in a database. Each individual table is refered to be a TableDef. For example, if "td" is the TableDef object that you have assigned as the tabledef for the table named "tblCustomer," then td.Name woud give you "tblCustomer"
    HTH

  5. #5
    Join Date
    Oct 2006
    Posts
    2
    Dim curDatabase As DAO.Database
    Dim tabObj As AccessObject

    Set curDatabase = CurrentDb

    For Each tabObj In dbs.AllTables
    Msgbox tabObj
    Next
    Last edited by pradyum_in; 10-25-2006 at 06:01 AM.

Posting Permissions

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