Solved

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

Posted on 2009-05-15
2
171 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Align a <div> to a table row 3 77
app server have enough resources... 2 42
ajaxSubmit is giving me an error 1 39
SSL Certificate for IIS7 Site 2 21
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

822 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