Ask a Question related to Coldfusion Database Access, Design and Development.
-
Jared@Itron #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 SQL query. The
thing is, I want to make the code more robust by allowing a variable number of
columns. Namely, if someone adds another column to the SQL table such as
hobbies, I don't want to have to change the code. I found an SQL query to get
the colum names in the order they appear in the table. I search for the record
in the table by account number. My question is, when I get the one row back
from the query is there a way to loop through that row without knowing the
column names, thereby allowing the code to automatically pick up on new
columns? Thanks in advance for your time and help. This is a great forum for
getting good answers.
-Jared
Jared@Itron Guest
-
how to get data grid column names
Hi, Can any one tell me how to get column names fro a datagrid. Is their any property or collection containing them Regards Swapnil D. ... -
#38054 [Asn->Fbk]: PDO with db2 returning column names but not data
ID: 38054 Updated by: wez@php.net Reported By: john dot enevoldson at pulsen dot se -Status: Assigned +Status:... -
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... -
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: ... -
No column names
Hi, Change the value of DESCSTAT from NO to YES and reassemble DSNZPARM. Vesna Frank wrote: -
paross1 #2
Re: Getting column data without column names
This is a simple example of dynamically displaying your column names and data
in a table. They will, however, be listed in alphabetical order.
<cfquery name="Q1" datasource="your_dsn">
SELECT *
FROM your_table
WHERE whatever
</cfquery>
<cfif IsDefined("Q1.ColumnList")>
<table border="1">
<tr><cfloop list="#Q1.ColumnList#" index="col" delimiters=",">
<th align="left" nowrap><cfoutput>#col#</cfoutput></th>
</cfloop></tr>
<cfoutput query="Q1">
<tr><cfloop list="#Q1.ColumnList#" index="col">
<td align="left" nowrap>#Q1[col][CurrentRow]#</td></cfloop></tr>
</cfoutput>
</table>
</cfif>
Phil
paross1 Guest
-
Dan Bracuk #3
Re: Getting column data without column names
Originally posted by: Jared@Itron
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 SQL query. The
thing is, I want to make the code more robust by allowing a variable number of
columns. Namely, if someone adds another column to the SQL table such as
hobbies, I don't want to have to change the code. I found an SQL query to get
the colum names in the order they appear in the table. I search for the record
in the table by account number. My question is, when I get the one row back
from the query is there a way to loop through that row without knowing the
column names, thereby allowing the code to automatically pick up on new
columns? Thanks in advance for your time and help. This is a great forum for
getting good answers.
-Jared
You had better hope the new field is not a date field.
Dan Bracuk Guest
-
Jared@Itron #4
Re: Getting column data without column names
Why is that? Also, once I have this dynamic list of column names and text
input fields with the current data already in them, how do I Update the SQL
table? Do I have to dynamically reference each column in that row to put the
new data in them? I have to name the text inputs dynamically to give them
different names as in name="param#count#". I can't use that within two other #
signs to update the table as in name=#param#count##.
Jared@Itron Guest
-
Dan Bracuk #5
Re: Getting column data without column names
Do a simple test.
Create a table add a record, and run paross1's code against it. Then add a date field, set it to something and rerun paross1's code.
Dan Bracuk Guest



Reply With Quote

