Skip to main content
July 10, 2009
Answered

Can't Update Table With Form Data in SQL Statement

  • July 10, 2009
  • 1 reply
  • 4998 views

Hi. Attached is the zip file of the error and the 2 cfm pages.... selectstudents.cfm goes first.

THe issue I am having is that the database is not being updated when I run the editroster.cfm page, submitted from the selectstudents.cfm page. The students #FORM.Period#_Class column should be filled with the #URL.ClassID# if the checkbox is checked on the selectstudents.cfm page.

Thanks for the help! It's appreciated

This topic has been closed for replies.
Correct answer craigkaminsky

OK. I get

Missing argument name.

When using named parameters to a function, every parameter must have a name.

The CFML compiler was processing:

  • An expression beginning with ListQualify, on line 17, column 24.This message is usually caused by a problem in the expressions structure.
  • The body of a cfquery tag beginning on line 14, column 2.
  • The body of a cfquery tag beginning on line 14, column 2.
The error occurred in D:\program files\Apache Software Foundation\Apache2.2\dev.intranet\AITE_Test_System\secure\Management\ClassMgr\editroster.cfm: line 17
15 : UPDATE students
16 : SET A1_Class = <cfqueryparam cfsqltype="cf_sql_varchar" value="#URL.ClassID#" />
17 : WHERE Ad_Username IN (#ListQualify(Form.Checkbox,')#)
18 : </cfquery>
19 : <cfcatch type="any">


I swear I may kill this forum's rich text editor before the day is done (it can't possibly be me ). It stripped part of the code from the ListQualify function. It should be

WHERE Ad_Username IN (#ListQualify(Form.Checkbox,"'")#)

The single quote was somehow unwrapped from the double quotes surrounding it.

1 reply

Inspiring
July 10, 2009

It might be an issue with your WHERE clause. In looking at the selectstudents.cfm file, the data for your checkbox appears to be a string (AD_Username field) but the WHERE clause is built for evaluating integers.

Try: WHERE AD_Username IN <cfqueryparam value="#FORM.checkbox#" cfsqltype="cf_sql_varchar" list="true" />

This will properly format the list items for a varchar (or other string-based) field to something along the lines of:

WHERE AD_Username IN ('Item1','Item2','Item3',etc)

July 10, 2009

Thanks, I tried that, but now i get "Incorrect syntx near '@P1'... @P1 doesn't even exist in any table...

Inspiring
July 10, 2009

UM, OK. This is what I get with the output... (and I fixed the typo first)

http://idisk.mac.com/macwiz1220-Public/CFError.pdf


I figured they were nvarchar or varchar but just wanted to make sure! Thanks.

One more test. Change the where clause to the following:

WHERE Ad_Username IN (#ListQualify(Form.Checkbox,"'")#)