Skip to main content
Known Participant
November 27, 2008
Question

What is wrong with this code - will not update

  • November 27, 2008
  • 4 replies
  • 421 views
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
    This topic is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    December 1, 2008
    Good debug path Dan. Guess we're betting on zero :-)
    Inspiring
    November 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#">
    Inspiring
    November 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/
    Known Participant
    November 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.