Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating multiple rows

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do you update multiple rows in a table? There is a checkbox for each row. If there is 1 or more checkbox checked I want those rows to be updated when the submit button is pressed.

Thanks
 
it's a sql problem ! either have a "larger" where clause (to allow more than 1 line) or do as many query as you have updates (1st solution's better !)
 
if the "update" is the same for each row, you can use

update your_table
set your_column = your_value
where your_table_id in (#form.name_of_the_checkbox#)

assuming all your checkbox have the same name.

don't forget to check if there is at least one checkbox checked.
 
This is what I have on the action page

<cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;#form.recordcount#&quot;>
<cfparam name=&quot;linkbroken&quot; default=&quot;0&quot;>
<cfset locsongid=&quot;form.songid&quot; & i>
<cfset loclinkbroken=&quot;form.linkbroken&quot; & i>

<cfquery datasource=&quot;VhDatabase&quot; name=&quot;update&quot; dbtype=&quot;ODBC&quot;>
update musicselection
set linkbroken='#Evaluate(loclinkbroken)#'
where songid='#Evaluate(locsongid)#'
</cfquery>
</cfloop>

This is the error I get

Error Occurred While Processing Request
Error Diagnostic Information
ODBC Error Code = 22005 (Error in assignment)


[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.



The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (22:1) to (22:61).


Date/Time: 12/13/00 10:48:37
Browser: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
Remote Address: 127.0.0.1
HTTP Referer:
 
if #Evaluate(locsongid)# is an integer, don't put the ''
idem for #Evaluate(loclinkbroken)#
 
I took them out it still doesn't work.

I get this error
An error occurred while evaluating the expression:

#Evaluate(loclinkbroken)#

Error near line 18, column 18.

An error has occurred while processing the expression:

form.linkbroken2

Error near line 1, column 1.

Error resolving parameter FORM.LINKBROKEN2

The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name.


The error occurred while processing an element with a general identifier of (#Evaluate(loclinkbroken)#), occupying document position (18:17) to (18:41).



 
When the checkbox is not checked, the action page doesn't receive the form so the form.XXX is not defined.

You can either use cfparam, perhaps that's what you wanted to do with :
<cfparam name=&quot;linkbroken&quot; default=&quot;0&quot;>
but the end of the name is missing.

or you can check if the variable is defined before using it :
<cfif Isdefined(&quot;form.linkbroken2&quot;)>your code</cfif>



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top