Syntax error in Where Statement

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Syntax error in Where Statement

    Having a problem with what the server says is a syntax error in the Where
    statement, but cant figure out where it is.

    <cfif IsDefined('URL.RecordID') OR IsDefined('Form.RecordID')>
    <cfif IsDefined('URL.RecordID')>
    <cfset RecordID=URL.RecordID>
    <cfelse>
    <cfset RecordID=Form.RecordID>
    </cfif>
    <cfelse>
    <cfabort showerror="The RecordID must be passed to this template">
    </cfif>
    <cfif IsDefined('Form.RULES_Delete')>
    <cfquery name="DeleteRecord" datasource="#Request.databaseA#" dbtype="ODBC">
    DELETE FROM RULESID
    WHERE ID=#variables.RecordID#
    </cfquery>
    <cfset Deleted=true>
    </cfif>
    <!--- inserted this into code to see if that changed the date to follow
    fomat --->
    <cfset DATE='#DateFormat("#Now()#", "mm/dd/yyyy")# #TimeFormat("#Now()#",
    'hh:mm:sstt')#'>

    <cfif IsDefined('Form.RULES_Edit')>
    <cfquery name="UpdateRecord" datasource="#request.databaseA#" dbtype="ODBC">
    UPDATE RULES
    SET
    NAME='#Form.NAME#',TEXT='#Form.TEXT#',EDITOR='#For m.EDITOR#',EDITOR_EMAIL='#Form
    ..EDITOR_EMAIL#',DATE='#Form.DATE#'
    WHERE ID=#form.variables.RecordID# <---- is where the error occurs
    </cfquery>
    <cfset Updated=true>
    </cfif>

    <CFQUERY name="GetRecord" dataSource="mw4off" maxRows=1>
    SELECT *
    FROM RULES
    WHERE ID = #variables.RecordID#
    </CFQUERY>

    Any help would be appreciated here.

    Running windows 2003 server sp1 and Coldfusion Mx 7 server

    Thanks

    Battle Guest

  2. Similar Questions and Discussions

    1. Syntax error in UPDATE statement.
      ok i have an update form that i created it is for the admin of the site to add/edit user account info for memebers to login. the form adds or edits...
    2. Syntax error in INSERT INTO statement
      I have a two table setup in fact I am doing the blog tutorial on Macromedia but with Access and asp I have two tables topic and articles I have a...
    3. Syntax Error Update Statement
      Can someone tell me what's wrong with this code? I need help. Thanks! It is an update page. FIRST PAGE: LOGIN CHECK <!--- Filename: ...
    4. syntax error in replace statement
      What's wrong with this code? strLongDesc = Replace(Replace(Replace(Replace(Trim(Request.Form("LongDesc")),"'","''"),vbC...
    5. Syntax Error In Update Statement
      I'm having a problem getting one piece of code to work on my app. It's a simple password change. For some reason, I've been getting the following...
  3. #2

    Default Re: Syntax error in Where Statement

    ok in the where statement above, the code should read

    WHERE ID=#variables.RedordID#
    Battle Guest

  4. #3

    Default Re: Syntax error in Where Statement

    Try the attached code.



    <cfif IsDefined('URL.RecordID') OR IsDefined('Form.RecordID')>
    <cfif IsDefined('URL.RecordID')>
    <cfset RecordID = Trim (URL.RecordID)>
    <cfelse>
    <cfset RecordID = Trim (Form.RecordID)>
    </cfif>
    <cfelse>
    <cfabort showerror="The RecordID must be passed to this template">
    </cfif>

    <cfif IsDefined('Form.RULES_Delete')>
    <cfquery name="DeleteRecord" datasource="#Request.databaseA#"
    dbtype="ODBC">
    DELETE FROM RULESID
    WHERE ID=#variables.RecordID#
    </cfquery>
    <cfset Deleted=true>
    </cfif>

    <!--- inserted this into code to see if that changed the date to follow fomat
    --->
    <cfset DATE='#DateFormat("#Now()#", "mm/dd/yyyy")# #TimeFormat("#Now()#",
    'hh:mm:sstt')#'>

    <cfif IsDefined('Form.RULES_Edit')>
    <cfquery name="UpdateRecord" datasource="#request.databaseA#"
    dbtype="ODBC">
    UPDATE
    RULES
    SET
    NAME ='#Form.NAME#', <!--- "Text" will not scale!
    Rename the column. --->
    [TEXT] ='#Form.TEXT#', <!--- "Text" will not scale!
    Rename the column. --->
    EDITOR ='#Form.EDITOR#',
    EDITOR_EMAIL ='#Form.EDITOR_EMAIL#',
    <!--- XXXXXX Is Date stored as text or datetime?!?
    Use the appropriate set statement.

    [DATE] ='#Form.DATE#' <!--- "Date" is a reserve word!!
    Rename the column. --->
    --->
    [DATE] =#CreateODBCDate (Trim (Form.DATE))#'
    WHERE
    ID=#variables.RecordID#
    </cfquery>
    <cfset Updated=true>
    </cfif>

    <CFQUERY name="GetRecord" dataSource="mw4off" maxRows=1>
    SELECT *
    FROM RULES
    WHERE ID = #variables.RecordID#
    </CFQUERY>

    MikerRoo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139