Error that I can't figure out

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

  1. #1

    Default Error that I can't figure out

    ----------------------------------------------------------------
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC
    Microsoft Access Driver] Syntax error in INSERT INTO statement.

    The error occurred in C:\CFusionMX\wwwroot\Test\update.cfm: line 67

    65 : <cfelse>
    66 : NULL
    67 : </cfif>
    68 : )
    69 : </cfquery>

    SQL INSERT INTO Legal Issues (title, link,"date") VALUES ( 'test' ,
    'www.test.com' , #5/20/05# )
    DATASOURCE sp2
    VENDORERRORCODE -3502
    SQLSTATE 42000
    ---------------------------------------------------------------

    The entire code statement that the error occured in is as follows:
    ---------------------------------------------------------------
    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
    "lgl_issues">
    <cfquery datasource="sp2" password="************">
    INSERT INTO Legal Issues (title, link,"date") VALUES (
    <cfif IsDefined("FORM.title") AND #FORM.title# NEQ "">
    '#FORM.title#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.link") AND #FORM.link# NEQ "">
    '#FORM.link#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
    ###FORM.date###
    <cfelse>
    NULL
    </cfif> <----This is line 67
    )
    </cfquery>
    </cfif>
    ------------------------------------------------------------

    I have another query above it that was put together the exact same way
    with DW and it operates correctly but this one and the 4 more following
    don't work. Any thoughts?

    stillwaiting
    stillwaiting Guest

  2. Similar Questions and Discussions

    1. Help Error I cannot figure out !!!
      Hi, I am wondering if anyone knows how to fix this issue. I suddenly get an error "Access Denied. The file may not exist or there could be a...
    2. Invalid object name Error I can't figure Out
      This is the error I'm recieving: Error Executing Database Query. Invalid object name 'f_users'. The error occurred in...
    3. I can't figure it out! (CDO.Message.1 error '80070005' )
      I'm at my wits end! There are a ton of people out there that are receiving the following error: "CDO.Message.1 error '80070005'" and a number of...
    4. Databind Error -- cannot figure out why.
      I get the following error on Line 49 (UG1.DataBind()) only if the Select Stored procedure returns no records. I am using a dataadapter and a...
    5. How do you figure out the LDAP://? ("Error authenticating. Error authenticating user. The specified domain either does not exist or could not be contacted")
      Hi, I am using the example "Authenticate against the Active Directory by Using Forms Authentication and Visual Basic .NET": ...
  3. #2

    Default Re: Error that I can't figure out

    The error is related to the way you are passing the date, should be
    #CreateODBCDate(form.date)#

    Ken
    The ScareCrow Guest

  4. #3

    Default Re: Error that I can't figure out

    The ScareCrow wrote:
    > The error is related to the way you are passing the date, should be
    > #CreateODBCDate(form.date)#
    >
    > Ken
    Your going to have to elaborate a little more. Why does my code work for
    the first form but not for the other ones? Where am I supposed to put
    the above code? I tried putting your code in place of "#FORM.date# but
    it returned the same error. I'm new at this and I'm afraid I need a
    little more explanation.

    <cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
    ###FORM.date###
    <cfelse>
    NULL
    </cfif>

    Thanks for the help so far,
    stillwaiting
    stillwaiting Guest

  5. #4

    Default Re: Error that I can't figure out

    Why does my code work for the first form but not for the other ones?

    I don't know as I have not seen all the code, but I would assume there is a
    difference somewhere.

    The attached code is what you need

    Ken

    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
    "lgl_issues">
    <cfquery datasource="sp2" password="************">
    INSERT INTO Legal Issues (title, link,"date")
    VALUES (
    <cfif IsDefined("FORM.title") AND
    Len(Trim(FORM.title))>'#FORM.title#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.link") AND
    Len(Trim(FORM.link))>'#FORM.link#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.date") AND
    IsDate(FORM.date)>#CreateODBCDate(FORM.date)#<cfel se>NULL</cfif>
    )
    </cfquery>
    </cfif>

    The ScareCrow Guest

  6. #5

    Default Re: Error that I can't figure out

    Have you tried [date] rather than "date" for your column name that's a keyword.
    You probably also need [Legal Issues] for a table name since it has an
    embedded space in it. Better yet, rename everything in both the DB and your
    SQL, since for all I know, "link" may also be a keyword:

    tblLegalIssues
    fldTitle
    fldLink
    fldDate


    JMGibson3 Guest

  7. #6

    Default Re: Error that I can't figure out

    I'll give it a try. That sounds like it may do the trick.

    ScareCrow, the code you gave me still didn't work.

    stillwaiting

    JMGibson3 wrote:
    > Have you tried [date] rather than "date" for your column name that's a keyword.
    > You probably also need [Legal Issues] for a table name since it has an
    > embedded space in it. Better yet, rename everything in both the DB and your
    > SQL, since for all I know, "link" may also be a keyword:
    >
    > tblLegalIssues
    > fldTitle
    > fldLink
    > fldDate
    >
    >
    stillwaiting Guest

  8. #7

    Default Re: Error that I can't figure out

    Damn, can't believe I missed the space in the table name.

    JMGibson3 is correct and you should change the db, but the attached will also
    work

    Ken

    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
    "lgl_issues">
    <cfquery datasource="sp2" password="************">
    INSERT INTO [Legal Issues] ([title], [link],[date])
    VALUES (
    <cfif IsDefined("FORM.title") AND
    Len(Trim(FORM.title))>'#FORM.title#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.link") AND
    Len(Trim(FORM.link))>'#FORM.link#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.date") AND
    IsDate(FORM.date)>#CreateODBCDate(FORM.date)#<cfel se>NULL</cfif>
    )
    </cfquery>
    </cfif>

    The ScareCrow Guest

  9. #8

    Default Re: Error that I can't figure out

    The ScareCrow wrote:
    > Damn, can't believe I missed the space in the table name.
    >
    > JMGibson3 is correct and you should change the db, but the attached will also
    > work
    >
    > Ken
    >
    > <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
    > "lgl_issues">
    > <cfquery datasource="sp2" password="************">
    > INSERT INTO [Legal Issues] ([title], [link],[date])
    > VALUES (
    > <cfif IsDefined("FORM.title") AND
    > Len(Trim(FORM.title))>'#FORM.title#'<cfelse>NULL</cfif>,
    > <cfif IsDefined("FORM.link") AND
    > Len(Trim(FORM.link))>'#FORM.link#'<cfelse>NULL</cfif>,
    > <cfif IsDefined("FORM.date") AND
    > IsDate(FORM.date)>#CreateODBCDate(FORM.date)#<cfel se>NULL</cfif>
    > )
    > </cfquery>
    > </cfif>
    >
    How exactly does the #CreateODBCDate(FORM.date)# differ in function? I
    would actually prefer to have the date and maybe even time added to the
    DB automatically. Could someone point me in the right direction on
    figuring out how to do that?

    By the way, I renamed all the tables and columns in my DB and it works
    flawlessly now. Thanks a ton guys. You guys on these forums are a life
    saver for those of us that are learning.

    stillwaiting
    stillwaiting Guest

  10. #9

    Default Re: Error that I can't figure out

    createodbcdate passes an odbc date data type to the sql query, where as
    #FORM.date# passes a string.

    You should always keep dates as dates, the only time you should convert a date
    value is to display it to a user.

    To have the db automatically insert the current date/time in the column.
    Open you ms access db
    Click on the date/time column
    In the bottom pane you will see the word "default value" in the space next to
    this enter Now()
    Also under this is also "required"

    Now when you insert a record, do not include the date/time column in the
    insert sql statement and the current date/time will be entered.

    But, this will not enter the current date/time if the record is updated, this
    must be done in the sql statement.

    Ken


    The ScareCrow 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