The problem is that instead of posting these kinds of "questions" (which are
usually just hundreds of lines of code with the request to fix it), Erik
needs to read a book on ColdFusion and a book on SQL. I've asked (begged)
him to do this so many times that my fingers are numb, but he just refuses
to do it. So my proposal is that everyone just stop responding to his posts
until he a) figures out how to ask for help properly, b) reads a SQL book,
and c) reads a ColdFusion book. Everything he asks about is explained in
full detail in any book on these subjects, so at this point all he's doing
is wasting other people's time.
Erik, you've got to do this, that's all there is to it. You'll thank me
later.
On Fri, May 2, 2008 at 12:34 PM, Tom McNeer <[EMAIL PROTECTED]> wrote:
> There's a lot in your code that should probably be changed -- first, I'm
> assuming that the form/database code at the bottom of your post is NOT
> part
> of the same page as the form -- but you don't need the cfoutput tags in
> the
> processing code, or most of the hash signs, and you could avoid the use of
> Evaluate.
>
> But most importantly, there are two big problems in the database code if
> this is supposed to be an "update" (you say the user is modifying the
> answers.
>
>
> <cfif isDefined("form.fieldnames")>
> > <cfquery name="qryInsert" datasource="cfelsunrise" dbtype="odbc">
> >
> > insert into survey_results (surveyidfk, empID) values (#url.survey#,
> > #session.EmpID#)
>
>
> Here you're always doing an "insert" -- creating a new survey result
> record.
> Is that what you're really trying to do? You said "modify," but you're
> saving a new record.
>
> Then ...
>
> <CFLOOP LIST="#form.fieldnames#" Index="field">
> > <cfif #field# neq "btnSubmitSurvey" and #field# neq "btnSubmitSurvey2">
> >
> >
> > <cfquery name="qryInsert1" datasource="cfelsunrise"
> > dbtype="odbc">
> > delete from SurveyResultsDetail where idfk
> > =#qryInsert.newID#
> > insert into SurveyResultsDetail
> > (answer,surveyID,idfk) values
> >
> (#ListLast(Evaluate("Form.#field#"),"_")#,#url.survey#,#qryInsert.newID#)
> > </cfquery>
> > <cfelse>
> >
> > </cfif>
> > </CFLOOP>
>
>
> ..... you are trying to delete records from the Detail table based on the
> ID
> of the new record, and there aren't any in the first iteration of the
> loop.
> You just created the Results record. Then you're immediately inserting a
> record into the Details table. But you are doing this within the loop of
> the fieldnames, so the next iteration of the loop deletes the record you
> just created. At the end you have one Detail record, from the last
> iteration
> of the loop, and it's related to the new Result record you just created.
>
>
>
>
>
> --
> Thanks,
>
> Tom
>
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304706
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4