You can get a column list from the query itself.
QueryName.columnList
Not that you need it in your case.
If you wish you can use evaluate to output the data.
<cfloop query="getData">
<cfoutput query="getColumns">
#Evaluate("getData.#column_name#")#
</cfoutput><br>
</cfloop>
"tom muck" <[EMAIL PROTECTED]> on 09/26/2000 02:18:15 PM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc: (bcc: Jerry Tolentino/SIAC)
Subject: [CF-Talk] Dynamic query
I have a web page that displays a list of SQL databases in a select box.
The
user selects a database and a table, and is taken to a page where the
information is displayed from the database. At least, that's what I want
to do.
I can't figure out how to get the list of columns to be displayed in a
table. I
have a query that picks out the columns from the database table:
<cfquery name="getColumns" DBTYPE="OLEDB" DBNAME="#url.databases#"
PROVIDER="SQLOLEDB" DATASOURCE="mysource">
SELECT * from information_schema.columns where table_name = '#url.table#'
</cfquery>
And a query that gets the data from that table:
<cfquery name="getData" DBTYPE="OLEDB" DBNAME="#url.databases#"
PROVIDER="SQLOLEDB" DATASOURCE="mysource">
Select * from #url.table#
</cfquery>
but I don't know how I can display it, given the fact that the column names
are
variables. I tried the following:
<cfloop query="getData"><cfoutput
query="getColumns">#column_name#</cfoutput><br></cfloop>
but that just gives me the name of the column repeated for the number of
records.
Any ideas?
tom
---------------------------------------------------------------------------
---
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.