Hello, I am new to coding in general, and I am trying to get an action file to work so that my form can be updated. SQL update will work but cfupdate will not. WHY??? I can't figure it out and I feel like I have tried EVERYTHING. ANY SUGGESTIONS out there? My database is MICROsoft access. more details -- this works: <cfquery datasource="crcsignup"> UPDATE signuppractice SET Field1='#FORM.Field1#' WHERE ID=#FORM.ID# </cfquery> if i replace it with the cfupdate, it doesn't work: <cfupdate datasource="crcsignup" tablename="signuppractice"> and the error message is: The website cannot display the page HTTP 500 Most likely causes: The website is under maintenance. The website has a programming error. What you can try: Refresh the page. Go back to the previous page. More information This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying. For more information about HTTP errors, see Help.
What exactly are you trying to do? What would be the problem with updating your database with SQL Update?
The number of form fields being submitted varies, so, as far as I know, I need to use cfupdate to get around that. I've been trying to write a code to use SQL -- but I'm not sure how to approach it. Is it possible to use "conditional" statements in SQL... such as "if FORM.Field1 exists, SET Field1=#'#FORM.Field1#'??? I've tried several variations on that theme, but nothing has worked. Thanks!
Yes, you can nest a <cfif> statement within your SQL to do whatever you need. I never used cfupdate... I would just use cfif to see whether a field is blank or not, and if it's not blank, you can pull that value to use it wherever you need. You can hard code this for each form field, or you can be clever and do it dynamically. Specific details, maybe I can help. Or, there are some good tutorials I can point you in the correct direction.
HI, Because the number of fields being submitted varies, I need the update page to look for the fields that exist (cfloop list for fieldnames?) in the form and then update the corresponding table column with the value in that field. The fields are names Field1, Field2, Field3, etc. (up to Field60) and correspond to the table column with the same name. I've tried multiple approaches using cfloop index, collection etc. and I always get a HTTP 500 Internal Server error message -- this website cannot be displayed. AM I going about this the right way? Is it something to do with the database I'm using (Microsoft aCcess)? Latest code: <cfquery datasource="crcsignup"> UPDATE signuppractice set <cfloop list="#form.fieldnames#" index="thisfield"> thisfield=<cfqueryparam value="#(form[thisfield])#">, </cfloop> id = id WHERE ID=#FORM.ID# </cfquery>
HELLO, THANKS FOR THE IDEAS. Turns out I had named my button "SAVE" which was then recognized as a formfield when I tried to update and because there was no corresponding "sAVE" column I received the error. THE SOLUTION: don't name the buttons! Now the <cfupdate> tag works fine.