Professional Web Applications Themes

querying field / column names in Access table - Coldfusion - Getting Started

I got great info on my last post, so let's try this one and see if my luck is still good: I have an Access table with about 30+ columns / fields in it. Instead of outputting those fields by referencing them in the code, is there a special tag or outputting structure that will allow me the ability to just loop through the field names without knowing what they are? TIA...

  1. #1

    Default querying field / column names in Access table

    I got great info on my last post, so let's try this one and see if my luck is
    still good:

    I have an Access table with about 30+ columns / fields in it. Instead of
    outputting those fields by referencing them in the code, is there a special tag
    or outputting structure that will allow me the ability to just loop through the
    field names without knowing what they are?

    TIA

    Brian Gallutia Guest

  2. #2

    Default Re: querying field / column names in Access table

    query.columnlist

    here's an example:
    <table border="1">
    <cfoutput query="myquery">
    <cfif currentrow eq 1><tr><cfloop list="#COLUMNLIST#"
    index="col"><th>#col#</th></cfloop></tr></cfif>
    <tr><cfloop list="#COLUMNLIST#"
    index="col"><td>#Evaluate("#col#")#</td></cfloop></tr>
    </cfoutput>
    </table>

    Kronin555 Guest

  3. #3

    Default Re: querying field / column names in Access table

    Thanks!

    So this was my complete query (I use relative instead of DSN)


    <CFQUERY NAME="listcol"
    DataSource="whocares"
    DBType="OLEDB"
    Username="Admin"
    PassWord="password"
    Provider="Microsoft.Jet.OLEDB.4.0"
    ProviderDSN="#mydb#\#DBNAME#">
    SELECT *
    FROM #URL.table#
    </CFQUERY>
    <table border="1">
    <cfoutput query="listcol">
    <cfif currentrow eq 1><tr><cfloop list="#COLUMNLIST#"
    index="col"><th>#col#</th></cfloop></tr></cfif>
    <tr><cfloop list="#COLUMNLIST#"
    index="col"><td>#Evaluate("#col#")#</td></cfloop></tr>
    </cfoutput>
    </table>

    manylists Guest

  4. #4

    Default Re: querying field / column names in Access table

    Hmm one more thought. Would it be possible to list the type of field it is? Ie primary key, text memo etc.

    Thanks

    Km
    manylists Guest

Similar Threads

  1. names in in table column with predefined width
    By rrrki in forum Brainstorming Area
    Replies: 0
    Last Post: July 7th, 12:12 AM
  2. Pulling table column names
    By Matthew in forum Coldfusion Database Access
    Replies: 1
    Last Post: June 30th, 07:57 PM
  3. querying table names in a database
    By Brian Gallutia in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: April 20th, 04:43 PM
  4. Replies: 3
    Last Post: June 30th, 05:09 AM
  5. Replies: 1
    Last Post: June 29th, 08:40 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139