Solved

How do i create a form by querying the tables collumn names, I think i am close.

Posted on 2009-05-15
2
169 Views
Last Modified: 2013-12-24
I am attepting to build a form by looping the collumn names of a query.
I am returning the collumn names, data_types, and max lengths I am getting this error.
The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag.

I am stumped.

God bless.
<cfquery datasource = "#dsn#" name="thequery">

select column_name as collumnName, data_type as dataType, character_maximum_length as maxlength from information_schema.columns

where table_name = 'myTable'

</cfquery>
 

<body>

<cfoutput>

<cfdump var="#thequery#">

</cfoutput> <!---  This successfully returns all collumn names , data_types and max lengths --->

<cfform target="_self" method="post" preloader="no">

<cfloop query="#thequery#"> <!---  I get the error at this line of code ---> 

<cfif datatype EQ "nvarchar">

<cfoutput>

<cfinput type="text" name="#CollumnName#" maxlength="#maxlength#" label="#collumnName# #datatype#">

</cfoutput>

</cfif>

</cfloop>
 
 

</cfform><!------>

Open in new window

0
Comment
Question by:LeadCo
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 24397369
> <cfloop query="#thequery#"> <!---  I get the error at this line of code --->

Do not use # signs. The value should be a string (ie the name of your query).  

         <cfloop query="thequery">

When you use # signs, you are passing in the query _object_ which is a complex object (ie not what cfloop is expecting).
0
 

Author Closing Comment

by:LeadCo
ID: 31581917
Thanks.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Coldfusion Mysql get data from two tables 3 78
UPLOAD FILE TO Web API USING POST 5 107
Passing value to a stored procedure 8 93
Domino Website - Redirection 12 54
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now