In addition to the query result, a query returns the following properties:

RecordCount  total number of records returned by the query
ColumnList   a comma-delimited list of the query columns
CurrentRow   the current row being processed when using CFOUTPUT

You reference them as query scoped variables, eg.

<CFQUERY NAME="QryA" ...>
        SELECT ...
</CFQUERY>

<CFOUTPUT>
        Number of Records = #QryA.RecordCount#
</CFOUTPUT>

The property you are interested in is the ColumnList.  Since this is a
comma-delimited list with all of the column names, you can process it using
any of the CF list functions, and loop over it using CFLOOP.

Phill Addorisio
AllianzWeb


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Mike Lau
Sent: May 13, 2002 2:31 PM
To: [EMAIL PROTECTED]
Subject: [CFTALKTor] getting query field name


hi all,

i know that we can loop through the Form object to get the field name from
the submitted data set, like the following:
<CFLOOP INDEX="FormField" LIST="#Form.FieldNames#">#FormField#</CFLOOP>
OR
<CFLOOP INDEX="FormField" LIST="#StructKeyList(Form)#">#FormField#</CFLOOP>

so I guess we can do the same thing for Query, ie: loop through the db query
and get all the column name.

In ASP it's something like
<% for i = 0 to RecordSet.Fields.Count - 1 %>
        <%=RecordSet.Fields(i).name%>
<%next%>

in java it's just about the same thing using
ResultSetMetaData.getColumnName(i)


what about in CF?  anybody can tell me how to do this?


rgds,

=============================
Mike Lau
Web Developer

[EMAIL PROTECTED]
User In Mind Creative Group Inc.

http://www.userinmind.com
Toll Free: 1-866-294-6644
T: (416) 490-7556
F: (416) 490-6889
=============================

-
You are subscribed to the CFUGToronto CFTALK ListSRV.
This message has been posted by: "Mike Lau" <[EMAIL PROTECTED]>
To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/
Manager: Kevin Towes ([EMAIL PROTECTED]) http://www.CFUGToronto.org/
This System has been donated by Infopreneur, Inc.
(http://www.infopreneur.net)


-
You are subscribed to the CFUGToronto CFTALK ListSRV.
This message has been posted by: "Phill Addorisio" <[EMAIL PROTECTED]>
To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/
Manager: Kevin Towes ([EMAIL PROTECTED]) http://www.CFUGToronto.org/
This System has been donated by Infopreneur, Inc.
(http://www.infopreneur.net)

Reply via email to