Susan, is it that you are getting two values for the formfield that
you are evaluating? Does the form you're sending from have more than
one field with the same name? It looks like that might be what's
causing the mismatch of quantity of columns vs. inserted values. If
you expect to have more than one value in that last item (for
multiple records) would a cfloop for the insert be more practical?
Regards, Palyne
On 7 Aug 2001, at 14:45, Susan N. Klos wrote:
From: "Susan N. Klos" <[EMAIL PROTECTED]>
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
Subject: RE: Processing a list
Date sent: Tue, 7 Aug 2001 14:45:24 -0400
Send reply to: [EMAIL PROTECTED]
I tried referencing #Evaluate("form.#i#")# just as you said, but I am not
sure I am referencing it in the correct place. changed my code to look like
this on the action page:
<cfif isdefined("form.fieldnames")>
<cfloop list="#form.fieldnames#" index="i"> (I still think it has to do with
this line right here. It appears to be looping through the first list's
fieldnames. Is there any way to set this list equal to anything else?)
<cfset PolicyNumber = right(i, len(i) - 2)>
<cfif left(i, 1) IS "d">
<cfset district = 1>
<cfelse>
<cfset district = 0>
</cfif>
<cfif left(i, 1) IS "s">
<cfset School = 1>
<cfelse>
<cfset School = 0>
</cfif>
<cfoutput>#session.DistrictID# #Evaluate("form.#i#")# #district#
#School#</cfoutput><br> (note: I put that evaluate here)
<cfquery datasource="#application.db#">
Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber)
Values ('#session.DistrictID#', '#District#', '#School#',
#Evaluate("form.#i#")#)(note: I put the evaluate here also.)
</cfquery>
The error now reads:
Error Diagnostic Information
ODBC Error Code = 21S01 (Insert value list does not match column list)
[Microsoft][ODBC Microsoft Access Driver] Number of query values and
destination fields are not the same.
SQL = "Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber)
Values ('xMe', '0', '0', 2,6)"
Data Source = "SDFS"
The error occurred while processing an element with a general identifier of
(CFQUERY), occupying document position (62:1) to (62:39) in the template
file C:\Inetpub\ccDir\WebPage2001\ProcessPage7.cfm.
The 2,6 are coming from Target Group which apparently getting processed
again when the above loop runs.
-----Original Message-----
From: Billy Cravens [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 07, 2001 1:59 PM
To: [EMAIL PROTECTED]
Subject: Re: Processing a list
It's your CFQuery. Look at the SQL generated:
Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber) Values
('xMe', '0', '0', OUPNUMBER)
"OUPNUMBER" is specified as a string with no quotes around it. In most
RDBMS's, this would mean it's a function, unless it's a number. Obviously
it's not a function; I'm assuming it's supposed to be a number. Look to
your loop: you're building #policynumber# as X number of characters
(depending on the length) of the field NAME; I'm assuming you're wanting to
compile it from field values. To do that, reference #Evaluate("form.#i#")#
instead of #i#
>From: "Susan N. Klos" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: "DFWCFUG (E-mail)" <[EMAIL PROTECTED]>
>Subject: Processing a list
>Date: Tue, 7 Aug 2001 13:08:33 -0400
>
>I have two lists and a text area on a form page. The lists are tables with
>checkboxes. On the action page, the first list processes fine, however,
>the
>second does not (I haven't gotten to checking the text area yet). Here is
>the form:
><html>
><head>
><title>Page 7</title>
></head>
>
><body>
><form name="TargetGroups" action="ProcessPage7.cfm" method="post">
><table cellspacing="0" cellpadding="0" ><tr><td align="justify" ><font
>color="Navy" ><b>
>
>B. Target Groups -- Indicate with a check mark the target groups that
>received project services during the 2000 - 2001 SDFS Project
>period.</b></font>
></td></tr></table><br>
>
><cfoutput query="qryTargetGroup">
><table border="1"><tr><td>
><!--- <input type="Hidden" name="DistrictId" value="#session.DistrictID#">
>--->
><td><input type="Checkbox" value="#Groupnumber#" name="Groupnumber"></td>
></td><td><font size="-1" style="TimesNewRoman">
>#groupname#</font></td></tr></table>
></cfoutput>
><br><br>
>
><b><font color="Navy">
>
>C. District/School Policies/Practices</font></b><br><font color="Navy">
>1. In the chart below, place a check mark in the boxes that reflect the
>ATOD
>use and violence prevention policies enforced in your district, or in some
>schools in your district. Indicate whether the policy is a district policy
>or a school option. (Note: The district Safe Schools Survey responses
>should provide information on many of these.)</font>
>
><table border="1"><tr><th>District Policy</th><th>School
>Option</th></tr><tr>
><cfoutput query="qryPolicy">
><!--- <td><input type="hidden" value="#Policynumber#"
>name="Policynumber"></td> --->
><td><input type="checkbox" value="Yes" name="d_#policynumber#"> </td>
><td><input type="Checkbox" value="Yes" name="s_#policynumber#"> </td>
><td><font size="-1" style="TimesNewRoman"> #Policyname#</font></td></tr>
></cfoutput>
></table><br><br>
><table>
><tr><td><font color="navy">
>
>C. 2. List the "Hot Topics" offered in the district through the 2000-2001
>SDFS Project. (Use this format: Hot Topic1, Hot Topic2, Hot Topic3, etc.)
>When you are finished typing in the information click SUBMIT at the end.
></font></td></tr>
>
>
> <cfoutput query="qryHotTopics">
> <tr><td><textarea NAME="HotTopic" ROWS="10" COLS="40"
>Wrap="virtual">#HotTopic#
> </textarea></td></tr>
></table>
></cfoutput>
>
><input type="Submit" value="SUBMIT">
>
></form>
>
>
></body>
></html>
>Here is the processing page:
><cfif isdefined("GroupNumber")>
><cfloop list="#GroupNumber#" index="x">
><cfquery datasource="#application.db#">
>Insert into tlnkTargetGroups (DistrictID, GroupNumber)
>Values ('#session.DistrictID#', #x#)
>
></cfquery>
>
></cfloop>
></cfif>
>
><cfif isdefined("form.fieldnames")>
><cfloop list="#form.fieldnames#" index="i">
><cfset PolicyNumber = right(i, len(i) - 2)>
><cfif left(i, 1) IS "d">
> <cfset district = 1>
><cfelse>
> <cfset district = 0>
></cfif>
><cfif left(i, 1) IS "s">
> <cfset School = 1>
><cfelse>
> <cfset School = 0>
></cfif>
>
><!--- <cfoutput>#session.DistrictID# #right(i, len(i) - 2)# #district#
>#School#</cfoutput><br> --->
>
><cfquery datasource="#application.db#">
> Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber)
> Values ('#session.DistrictID#', '#District#', '#School#', #PolicyNumber#)
></cfquery>
>
>
><!--- </cfif> --->
></cfloop>
>
><cfif isdefined("form.HotTopics")
><cfupdate datasource="#Application.db#" tablename="tblDistrictInfo"
>dbtype="ODBC"
> formfields="DistrictID, HotTopic">
></cfif>
>The first <cfloop list="#GroupNumber#" index="i"> processes fine. The
>second one <cfloop list="#Form.FieldNames#" index="i"> does not. I haven't
>even gotten to processing the text area yet. I think the processing is
>breaking down because of the list="#Form.fieldnames#". It loops through
>all
>the fieldnames on the form not just the second group. I am sure this is
>true because if I do not put any checkmarks in the first group it processes
>fine. I feel I have tried every combination of list=(something) and I
>can't
>seem to come up with the solution. When I try the above code and put
>checkmarks in both groups, I get the following error:
>
>Error Diagnostic Information
>
>
>ODBC Error Code = 07001 (Wrong number of parameters)
>
>
>
>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
>
>
>Hint: The cause of this error is usually that your query contains a
>reference to a field which does not exist. You should verify that the
>fields
>included in your query exist and that you have specified their names
>correctly.
>
>
>SQL = "Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber)
>Values ('xMe', '0', '0', OUPNUMBER)"
>
>
>Data Source = "SDFS"
>
>
>
>The error occurred while processing an element with a general identifier of
>(CFQUERY), occupying document position (62:1) to (62:39) in the template
>file C:\Inetpub\ccDir\WebPage2001\ProcessPage7.cfm.
>
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org
-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org
-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org