Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

What is wrong with this code - will not update

New Here ,
Nov 26, 2008 Nov 26, 2008
I am attempting to use the following code to update a column in a table :

<cfloop from="1" to="#form.totalRows#" index="row">

<cfparam name="form.PartNumberID#row#">
<cfparam name="form.deliveryNumber#row#">

<cfset PartNumberID = form["PartNumberID"& row]>
<cfset deliveryNumber = form["deliveryNumber"& row]>

<cfquery name="qryUpdate" datasource="datasource">
update TABLE
set deliveryNumber = '#deliveryNumber#'
where (Rdn = #Rdn# and PartNumberID = #PartNumberID#)
</cfquery>

</cfloop>

It appears to execute successfully without any errors. Yet when I check the sql server, the deliveryNumber column in the table is still NULL and not updated with the valued entered in the form/screen.

I have used <cfoutput> to display all the values and they all come out as they should be (I selected one record to test and the variables displayed from cfoutput all correspond to the record)

I even took the update part and ran it thru the query analyzer and plugged in/hardcoded the values from the variables and the update works, the deliveryNumber column in the table is updated. So it appears the code is working.

Yet when I run it thru the application, it does not work and does not give any errors.

Can somebody tell me what the problem is, I just cannot see it ?

Thanks
421
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2008 Nov 27, 2008
you do not need those <cfparam> tags there - they serve no purpose.

check your where clause. where is the #Rdn# variable coming from?

you may want to just output your WHERE clauses as text inside your
cfloop to make sure the values you expect to be there are actually there.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 27, 2008 Nov 27, 2008
The #rdn# is a url variable that is pass to this form from another page. I put it in a hidden filed and originallly used it as from.rdn. That did not make a difference, so I just used rdn.

The cfoutput to display the rdn, partnumberid, deliverynumber, totalrows, and row, all display properly. I even use those in the query anlayzer and the update works.

I will remove the crparam and see if that makes any difference. This is very frustrating since there are no error messages and I am led to believe the code works.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2008 Nov 27, 2008
If this:
<cfquery name="qryUpdate" datasource="datasource">
update TABLE
set deliveryNumber = '#deliveryNumber#'
where (Rdn = #Rdn# and PartNumberID = #PartNumberID#)
</cfquery>

doesn't update your record, what happens when you do this?
<cfquery name="qryUpdate" datasource="datasource">
select count(*) from TABLE
where (Rdn = #Rdn# and PartNumberID = #PartNumberID#)
</cfquery>
<cfdump var="#qryUpdate#">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 30, 2008 Nov 30, 2008
LATEST
Good debug path Dan. Guess we're betting on zero 🙂
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources