Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    25

    Arrow Unanswered: get the names of fields from a view

    is this possible? i can do it from a table...

    oServer.Databases.Item(sDatabase).Tables.Item(sTab le).Columns.Item(iLoop).Name

    but i also need the names of columns from a view, so...

    oServer.Databases.Item(sDatabase).Views.Item(sView ). ???

    any help would be much appreciated, thank you!!!

  2. #2
    Join Date
    May 2003
    Posts
    25

    Cool Re: get the names of fields from a view

    Originally posted by kfenstad
    is this possible? i can do it from a table...

    oServer.Databases.Item(sDatabase).Tables.Item(sTab le).Columns.Item(iLoop).Name

    but i also need the names of columns from a view, so...

    oServer.Databases.Item(sDatabase).Views.Item(sView ). ???

    any help would be much appreciated, thank you!!!
    so... i figured out my own problem but i thought i would post it here in case anyone else would like to get view column info... which would be quite a coincidence! anyway...

    i just linked to the system tables in sql server where my view is, and then created a recordset.

    Set rsViewColumns = CurrentDb.OpenRecordset("SELECT dbo_syscolumns.name FROM dbo_sysobjects INNER JOIN dbo_syscolumns " _
    & "ON dbo_sysobjects.id = dbo_syscolumns.id WHERE dbo_sysobjects.name = '" & sView & "'")

    if "sView" is a string containing the name of the view, you get a recordset of all the column names. you also can get other info such as if the column is nullable or join the systypes table as well and get info about the column datatype. pretty easy!

Posting Permissions

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