Results 1 to 5 of 5

Thread: displaying a table's column name

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    displaying a table's column name

    Hi!!

    tnx for the info that uve given me before with regards to databases..

    i just want to know if there is a way to display a table's column name using vb6..

    my database is in access 2003 format


    tnx!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: displaying a table's column name

    There are several ways, but like with most things to do with database related code, which one(s) are valid depend on which connection technology you are using - such as ADO code/ADO control/DAO control/...

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    14

    Re: displaying a table's column name

    Im using Ado Code..

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: displaying a table's column name

    One way is to open a recordset containing all columns, but no rows:
    Code:
    Dim strSQL as String
    Dim intField as Integer
    Dim objRS as ADODB.Recordset
      strSQL = "SELECT * FROM Table1 WHERE False"
      objRS.Open strSQL, objCN, adOpenForwardOnly, adLockReadOnly, adCmdText
    
      For intField = 0 To objRS.Fields.Count -1
        MsgBox objRS.Fields(intField).Name
      Next intField
    
      objRS.Close
      Set objRS = Nothing
    Another is to use OpenSchema. You can see an example (for Tables rather than fields) here.

  5. #5
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: displaying a table's column name

    Querying the data dictionary is helpful, if you're using Oracle.

    sql Code:
    1. SELECT column_name from dba_tab_columns where table_name = 'TABLE'
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

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