problem with insert statement

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default problem with insert statement

    HI there

    it seems like i get the error when inserting records into a MS Access database
    if the fields are null. :

    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:\Inetpub\wwwroot\instreamWorks\Instream_Enter3.c fm:
    line 30
    Called from C:\Inetpub\wwwroot\instreamWorks\Instream_Enter3.c fm: line 1
    Called from C:\Inetpub\wwwroot\instreamWorks\Instream_Enter3.c fm: line 30
    Called from C:\Inetpub\wwwroot\instreamWorks\Instream_Enter3.c fm: line 1

    28 : <cfquery name="AddTrip" datasource="InstreamWorks">
    29 : INSERT INTO TBL_PROJECT_GEOREFERENCE (TBL_PROJECT_INFO_ID, EASTINGS,
    NORTHINGS)
    30 : VALUES (#getid.maxid#, #Form.EASTINGS#, #Form.NORTHINGS#)
    31 : </cfquery>
    32 :




    --------------------------------------------------------------------------------

    SQL INSERT INTO TBL_PROJECT_GEOREFERENCE (TBL_PROJECT_INFO_ID, EASTINGS,
    NORTHINGS) VALUES (93, , )
    DATASOURCE InstreamWorks

    ****************


    if the user fills out all the fields, then the records are inserted without a
    problem. this doesn't happen on other insert queries of mine.

    my code:

    <cfquery name="AddTrip" datasource="InstreamWorks">
    INSERT INTO TBL_PROJECT_GEOREFERENCE (TBL_PROJECT_INFO_ID, EASTINGS,
    NORTHINGS)
    VALUES (#getid.maxid#, #Form.EASTINGS#, #Form.NORTHINGS#)
    </cfquery>

    any ideas?

    thanks

    sviolet Guest

  2. Similar Questions and Discussions

    1. Help with INSERT INTO statement
      I'm getting the following error on a query. I haven't seen this one before. Any ideas on what I'm doing wrong? Thanks. Error Executing Database...
    2. INSERT statement contains fewer items than the insert list
      The block of code below shows how I am inserting field values into my dbase table: strSQLStatement = "INSERT INTO tblArticles...
    3. What am I doing wrong; problem with INSERT statement (ASP/MS ACCESS)
      Does column desc allow empty strings? "Simom Thorpe" <simonocthorpe@hotmail.com> wrote in message...
    4. Problem with IDENTITY and ORDER BY in a INSERT statement
      Peter, I think this is a minor bug with the SQL Server parser. I've passed it on to MS. Fortunately the workaround is simple. I'll also...
    5. Insert Statement help
      Hello, I am having some difficulty keeping my data consistent throughout my tables. I have 3 tables that I need to be "synch'd up"....
  3. #2

    Default Re: problem with insert statement

    Hi,
    are the fields eastings and northings integers? I dont mean to point out the
    obvious but just in case, dont forget the single quotes for them if they're
    textual fields.

    have you tried using <cfqueryparam> tags for the values as well?

    Cheers,
    Aegis

    A3gis Guest

  4. #3

    Default Re: problem with insert statement

    Thanks a3gis,

    Single quotes was not the problem but your suggestion to use cfqueryparam
    worked:


    <CFQUERY DATASOURCE="InstreamWorks" NAME="InsertGEO">
    INSERT INTO TBL_GEOREF (
    EASTINGS,
    NORTHINGS
    )
    VALUES (
    <cfqueryparam
    value="#Form.EASTINGS#"
    cfsqltype="CF_SQL_DOUBLE"
    >,
    <cfqueryparam
    value="#Form.NORTHINGS#"
    cfsqltype="CF_SQL_DOUBLE"
    >
    )

    </cfquery>


    sviolet Guest

  5. #4

    Default Re: problem with insert statement

    Cool :)

    note, anywhere you're receiving form or url variables into a query, it is very
    handy to use cfqueryparams, as they prevent users from being able to send
    spurious SQL commands through those fields to trigger DROP TABLE commands etc.
    Regards,
    Aegis

    A3gis 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