Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how to get table names in MS Access database [Solved]

how to get table names in MS Access database [Solved]

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadmintutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    K V Sekhar
    wrote on last edited by
    #1

    Hi, What is the query to get the list of table names for MS Access. In Sql Server : USE [MyDatabase] SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES In MS Access ? Thanks in advance.

    L 1 Reply Last reply
    0
    • K K V Sekhar

      Hi, What is the query to get the list of table names for MS Access. In Sql Server : USE [MyDatabase] SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES In MS Access ? Thanks in advance.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      SELECT
      Table_Name = Name,
      Row_Count = DCount("*",[MSysObjects].[Name])
      FROM
      MSysObjects
      WHERE
      (Left([Name],1)<>"~")
      AND (Left([Name],4) <> "MSys")
      AND ([Type] In (1, 4, 6))
      ORDER BY
      Name

      Source can be found here.

      I are Troll :suss:

      K 1 Reply Last reply
      0
      • L Lost User

        SELECT
        Table_Name = Name,
        Row_Count = DCount("*",[MSysObjects].[Name])
        FROM
        MSysObjects
        WHERE
        (Left([Name],1)<>"~")
        AND (Left([Name],4) <> "MSys")
        AND ([Type] In (1, 4, 6))
        ORDER BY
        Name

        Source can be found here.

        I are Troll :suss:

        K Offline
        K Offline
        K V Sekhar
        wrote on last edited by
        #3

        Hi Eddy, Thanks for your response. I got one more alternative for that...

        OleDbConnection con = new OleDbConnection("Provider=microsoft.jet.oledb.4.0; data source="+Server.MapPath("~/App_Data/Sample.mdb"));
        con.Open();
        DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"});
        con.Close();

        L 1 Reply Last reply
        0
        • K K V Sekhar

          Hi Eddy, Thanks for your response. I got one more alternative for that...

          OleDbConnection con = new OleDbConnection("Provider=microsoft.jet.oledb.4.0; data source="+Server.MapPath("~/App_Data/Sample.mdb"));
          con.Open();
          DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"});
          con.Close();

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          sekhar.k wrote:

          I got one more alternative for that...

          The .NET version would be preferable over an SQL-statement; it's obvious what the code does if you read your version. It's not that obvious what the query on the MSys tables does. Well done :)

          I are Troll :suss:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups