Passing database column names as varable

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Passing database column names as varable

    I've tried all night to figure this one out..And I can't seem to find the
    answear on the forums..

    I've made a CustomTag-file that need these attributes:

    KRISGRAPH.CFM:
    <CFPARAM NAME="Attributes.Database_ColumnName">
    <CFPARAM NAME="Attributes.DATASOURCE">
    <CFPARAM NAME="Attributes.TABLE">

    And then I pass the ColumnName to the CustomTag with these attribute values:
    INDEX.CFM:
    <CF_KRISGRAPH
    DATASOURCE="MYFIRM"
    TABLE="Customers"
    Database_ColumnName="Customer_Name"
    >
    And then i want to output the particular column values from
    #Attributes.Database_ColumnName#
    <cfquery name="Graph_01" datasource="#Attributes.DATASOURCE#">
    SELECT * FROM #Attributes.TABLE#
    </cfquery>

    <cfoutput query="Graph_01">
    #Attributes.Database_ColumnName#, <br>
    </cfoutput>

    The result is ofcourse only the Customer_Name and not the value of it...:
    Customer_Name,
    Customer_Name,
    Customer_Name,
    Customer_Name,

    I understand why it does it, but how can i get around it and nicly output the
    value of it instead?

    Cheers!


    KriZzZz Guest

  2. Similar Questions and Discussions

    1. Getting column data without column names
      Hello all, I'm trying to write a coldfusion program to display account data such as name, address, phone #, etc. I retrieve this data from an ...
    2. counting column and getting column names
      Im using an Access database that will probably be switched over to Oracle later, but I need to find out how to get the number of columns in an...
    3. HELP! Passing from database to asp page allowing user input then passing to another database.
      My big problem is I'm a newbie working with someone else's code.(See code below) What I want to do is for the records that have a purchase order...
    4. How to get column names using SQL?
      In article <a06d6e69.0307100719.2e206e69@posting.google.com>, minjie@excite.com says... SYSCAT.COLUMNS To show the columns of this view: ...
    5. No column names
      Hi, Change the value of DESCSTAT from NO to YES and reassemble DSNZPARM. Vesna Frank wrote:
  3. #2

    Default Re: Passing database column names as varable

    <CFPARAM NAME="Attributes.Database_ColumnName">
    <CFPARAM NAME="Attributes.DATASOURCE">
    <CFPARAM NAME="Attributes.TABLE">

    is not necessarily wrong. However, it's the usual practice to set the default
    values, thus

    <CFPARAM NAME="Attributes.Database_ColumnName" DEFAULT="Customer_Name">
    <CFPARAM NAME="Attributes.DATASOURCE" DEFAULT="MYFIRM">
    <CFPARAM NAME="Attributes.TABLE" DEFAULT="Customers">
    > how can i get around it and nicly output the value of it instead?
    <!--- Use query's structure-key format to identify each row, and iterate by
    means of in-built variable, currentrow --->
    <cfoutput query="Graph_01">
    #Graph_01#, <br>
    </cfoutput>


    BKBK Guest

  4. #3

    Default Re: Passing database column names as varable

    Your custom tag will run more quickly if you select only attributes.column_name instead of *.
    Dan Bracuk Guest

  5. #4

    Default Re: Passing database column names as varable

    Thank you so much! Love you!

    BKBK: Yeah, my bad, but i only narrowed the code here to focus on the actual
    problem i had. But the default values are going in there right this second. :)

    It worked perfectly, but I haven't seen that particular code before. Im quite
    on the "getting-started"-level of my coding.. As i translate it to my level of
    understanding, the is a variable in cold fusion that picks out a new row
    inside the loop..sort of? very neat :)

    Dan: Yeah. again, just to focus on the problem, so i did a fast example.

    Thanks again, both you!

    KriZzZz Guest

Posting Permissions

  • You may not post new threads
  • You may 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