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. Listing tables and views?

Listing tables and views?

Scheduled Pinned Locked Moved Database
databasecsharpsql-servervisual-studiosysadmin
5 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.
  • B Offline
    B Offline
    Bill Dean
    wrote on last edited by
    #1

    Hi all, I have an OleDbConnection object and I would like to be able to get a list of all the tables and views available through it. Do I need to know anything about the underlying database architecture to do this? For example, if it were mssql, I would know to query sysobjects. But if I do not know where the underlying database stores the data am I SOL? I suspect the answer is "no" because I can get a list of tables and views when I add this data connection to my server explorer in VS.NET but I haven't a clue how the do it in code. Thanks in advance, Bill

    D 1 Reply Last reply
    0
    • B Bill Dean

      Hi all, I have an OleDbConnection object and I would like to be able to get a list of all the tables and views available through it. Do I need to know anything about the underlying database architecture to do this? For example, if it were mssql, I would know to query sysobjects. But if I do not know where the underlying database stores the data am I SOL? I suspect the answer is "no" because I can get a list of tables and views when I add this data connection to my server explorer in VS.NET but I haven't a clue how the do it in code. Thanks in advance, Bill

      D Offline
      D Offline
      Dr_X
      wrote on last edited by
      #2

      The easiest way is to use the following query.

      Select name, type from Sysobjects
      where type = 'U'
      or type = 'V'

      The other way is to use ADOX. However, I have not used it in .Net only in the old VB world. Michael

      B 1 Reply Last reply
      0
      • D Dr_X

        The easiest way is to use the following query.

        Select name, type from Sysobjects
        where type = 'U'
        or type = 'V'

        The other way is to use ADOX. However, I have not used it in .Net only in the old VB world. Michael

        B Offline
        B Offline
        Bill Dean
        wrote on last edited by
        #3

        Michael, Thanks for the response! I did not realize it was that easy. Bill

        D 1 Reply Last reply
        0
        • B Bill Dean

          Michael, Thanks for the response! I did not realize it was that easy. Bill

          D Offline
          D Offline
          Dr_X
          wrote on last edited by
          #4

          I would recommend doing this from a stored procedure. Really don't want users messing around with sysobjects unless there very knowlegeable. Michael

          B 1 Reply Last reply
          0
          • D Dr_X

            I would recommend doing this from a stored procedure. Really don't want users messing around with sysobjects unless there very knowlegeable. Michael

            B Offline
            B Offline
            Bill Dean
            wrote on last edited by
            #5

            If I had sql server on the back-end...I would. But we are trying to get at data in Informix...which as far as I know doesn't support sprocs. Like I said before, I really a complete novice with this particular back-end so I was looking for a way to do this that generalized to all ado.net. Your suggestion works great btw, even with the Informix back-end. Thanks again. Bill

            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