Need Help with Record Insert Error

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

  1. #1

    Default Need Help with Record Insert Error

    Hi Coldfuschions,

    I am a novice and am trying to use the Record Insertion Form Wizard in
    D8/ColdFusion to add a record to a MS Access database. I had this working fine
    yesterday and somehow I am getting errors now, which I can't seem to circumvent
    on my own. The most puzzling part is that I am using the built in wizard and
    not handwriting any code, so it seems the wizard is producing bad code, which I
    would find to be surprising" Here is the code fragment that the wizard is
    generating that is causing the error: I bolded the line that the parser is
    barking about. Can anyone help?? Thanks!


    INSERT INTO [Path to my database and table] (Name, Date, Project,
    Activity, BillableHours, NonBillableHours)
    VALUES (
    <cfif IsDefined("FORM.Name") AND #FORM.Name# NEQ "">
    '#FORM.Name#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Date") AND #FORM.Date# NEQ "">
    '#FORM.Date#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Project") AND #FORM.Project# NEQ "">
    '#FORM.Project#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Activity") AND #FORM.Activity# NEQ "">
    '#FORM.Activity#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.BillableHours") AND #FORM.BillableHours# NEQ "">
    #FORM.BillableHours#
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.NonBillableHours") AND #FORM.NonBillableHours# NEQ "">
    #FORM.NonBillableHours#
    <cfelse>
    NULL
    <b></cfif></b>
    )
    </cfquery>
    <cflocation url="thanks.html">
    </cfif>

    manhattanmediaworks Guest

  2. Similar Questions and Discussions

    1. JavaScript error in Insert Record server behavior
      When I attempt to add an Insert Record server behavior in a VBScript-based ASP file, I get the following error message: "While executing onChange in...
    2. Insert Record (php) - Error, but I have a form on thepage!
      I am unable to create an INSERT RECORD behavior for php in DW04 because it says I must have a form. Problem is, I do have a form! I am selecting the...
    3. How to insert a new record
      I am having problems with inserting a new record into access database using the detailsview control, the autonumber of the control does not update...
    4. insert a record
      Hi every one, I have a problem inserting a record... error 500.100 (Operation must use an updateable query) or Unknown variable or something... ...
    5. Insert Record Error-502 Bad Gateway-HELP
      I hope someone can help me with this ASAP!! I am working with DW MX using the Insert Record feature. All of my form fields are named as well as ...
  3. #2

    Default Need Help with Record Insert Error

    Hi Coldfuschions,

    I am a novice and am trying to use the Record Insertion Form Wizard in
    D8/ColdFusion to add a record to a MS Access database. I had this working fine
    yesterday and somehow I am getting errors now, which I can't seem to circumvent
    on my own. The most puzzling part is that I am using the built in wizard and
    not handwriting any code, so it seems the wizard is producing bad code, which I
    would find to be surprising.

    Below is the code segment that the wizard is generating that is causing the
    error. I noted the line below that the parser is barking about (towards end of
    code segment). The connection to the db is good. Any ideas?? Thanks in
    advance for removing me from misery!


    INSERT INTO [Path to my database and table] (Name, Date, Project,
    Activity, BillableHours, NonBillableHours)
    VALUES (
    <cfif IsDefined("FORM.Name") AND #FORM.Name# NEQ "">
    '#FORM.Name#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Date") AND #FORM.Date# NEQ "">
    '#FORM.Date#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Project") AND #FORM.Project# NEQ "">
    '#FORM.Project#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Activity") AND #FORM.Activity# NEQ "">
    '#FORM.Activity#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.BillableHours") AND #FORM.BillableHours# NEQ "">
    #FORM.BillableHours#
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.NonBillableHours") AND #FORM.NonBillableHours# NEQ "">
    #FORM.NonBillableHours#
    <cfelse>
    NULL
    </cfif> <!--- This is the line that the parser is finding to be problematic
    --->
    )
    </cfquery>
    <cflocation url="thanks.html">
    </cfif>

    manhattanmediaworks Guest

  4. #3

    Default Re: Need Help with Record Insert Error

    Just checking, but is there start tags (i.e, <cfquery name="..." etc> and <cfif>) for both the </cfquery> and </cfif> at the end?
    sfbell Guest

  5. #4

    Default Re: Need Help with Record Insert Error

    For your specific problem, you have to look above the code you posted. Here
    are your last three lines of code.
    </cfquery>
    <cflocation url="thanks.html">
    </cfif>

    You need an opening cfif tag and cfquery tag, in that order.

    By the way, you should learn about database normalization. No sense having a
    database if the data is unuseable.

    Dan Bracuk Guest

  6. #5

    Default Re: Need Help with Record Insert Error

    sfbell/Dan, thanks for the replies...the whole code snippet is below and now
    you can see the opening tags.

    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
    <cfquery datasource="conn_hours">
    INSERT INTO [Path to my database/table] (Name, Date, Project, Activity,
    BillableHours, NonBillableHours)
    VALUES (
    <cfif IsDefined("FORM.Name") AND #FORM.Name# NEQ "">
    '#FORM.Name#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Date") AND #FORM.Date# NEQ "">
    '#FORM.Date#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Project") AND #FORM.Project# NEQ "">
    '#FORM.Project#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.Activity") AND #FORM.Activity# NEQ "">
    '#FORM.Activity#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.BillableHours") AND #FORM.BillableHours# NEQ "">
    #FORM.BillableHours#
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.NonBillableHours") AND #FORM.NonBillableHours# NEQ "">
    #FORM.NonBillableHours#
    <cfelse>
    NULL
    </cfif>
    )
    </cfquery>
    <cflocation url="thanks.html">
    </cfif>

    manhattanmediaworks Guest

  7. #6

    Default Re: Need Help with Record Insert Error

    What specific error are you getting? Also, are the BillableHours and NonBillableHours fields actually a numeric datatype in the database? If not, then you will need single quotes.

    Phil
    paross1 Guest

  8. #7

    Default Re: Need Help with Record Insert Error

    Error Occurred While Processing Request
    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 [path to my file]...TimeInputter2.cfm: line 40

    38 : <cfelse>
    39 : NULL
    40 : </cfif>
    41 : )
    42 : </cfquery>




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

    SQL INSERT INTO C:\CFusionMX7\db\raskin3.TimeEntries2 (Name, Date, Project,
    Activity, BillableHours, NonBillableHours) VALUES ( 'Phil Raskin' , 'asdf' ,
    'UMDNJ001' , 'Programming' , 3 , 3 )
    DATASOURCE conn_hours
    VENDORERRORCODE -3502
    SQLSTATE 42000

    Resources:



    manhattanmediaworks Guest

  9. #8

    Default Re: Need Help with Record Insert Error

    the <cfquery at the start needs a name="any_query_name" as well.
    sfbell Guest

  10. #9

    Default Re: Need Help with Record Insert Error

    The <cfquery> tag must always have name and datasource as required fields. This
    name is in case you ever need to reference the query on the page. The query
    name must always begin with a letter as well.

    sfbell Guest

  11. #10

    Default Re: Need Help with Record Insert Error

    I think that your problem is here --> SQL INSERT INTO <b>C:\CFusionMX7\db\raskin3.TimeEntries2</b> Shouldn't this be a DATASOURCE? I think Dreamweaver is messing you up (what a shock).

    Phil
    paross1 Guest

  12. #11

    Default Re: Need Help with Record Insert Error

    the datasource has been called in the <cfquery> datasource already, try just putting the table name after the insert into?
    sfbell Guest

  13. #12

    Default Re: Need Help with Record Insert Error

    Copy and paste
    INSERT INTO YourTableName
    (Name, Date, Project, Activity, BillableHours, NonBillableHours) VALUES
    ( 'Phil Raskin' , 'asdf' , 'UMDNJ001' , 'Programming' , 3 , 3 )
    into access and see if it runs. If not, start deleting fields and values
    until it does. The last field you delete will be the one that is causing the
    problem.

    I'm guessing it's the date.

    Dan Bracuk Guest

  14. #13

    Default Re: Need Help with Record Insert Error

    Before all hell breaks loose and all hair falls out, I decided to create a bare
    bones MS Access database with a couple of text formatted fields and with the
    wizard I was able to add rows. With each success I added more functionality
    and sure enough when I try to add a date I run into problems. These errors
    come up when I submit that value as text, date or date MS Access, in the
    'submit as' dropdown menu in the record insertion form wizard. I would use
    text when the field is formatted as text, and the latter two when the field in
    the db is formated as a date. I am totally stumped. When I put in a string
    into the date part, it works (when it is formatted as a string, but then when I
    input something like ''04/27/06" I get an error.

    manhattanmediaworks Guest

  15. #14

    Default Re: Need Help with Record Insert Error

    How about trying this?

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

    --or--

    you might consider using cfqueryparam tags in your VALUES specifying the
    appropriate cfsqltype, such as CF_SQL_TIMESTAMP CF_SQL_DATE, etc.

    Phil


    paross1 Guest

  16. #15

    Default Re: Need Help with Record Insert Error

    paross1, your first suggestion yielded this error:

    The error occurred in C:\CFusionMX7\wwwroot\hours\easyNameInputter.cfm: line 34

    32 : <cfelse>
    33 : NULL
    34 : </cfif>
    35 : )
    36 : </cfquery>


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

    SQL INSERT INTO C:\CFusionMX7\db\raskin4.HourLog (RecordID, "First Name",
    "Last Name", Activity, Date) VALUES ( NULL , 'Mike' , 'Wilson' , 'Graphic
    Design' , {d '2005-04-29'} )



    ultimately I want to include a javascript calendar pop up date picker - the
    issue seems to be getting the format of the field jiving between CF and Access.
    text works when text is expected, but I can't get dates to work. I am looking
    to do a mm/dd/yyyy format. This is so lame that the wizard is producing bad
    code. Nice experience for a new user

    manhattanmediaworks Guest

  17. #16

    Default Re: Need Help with Record Insert Error

    It might be more than that. Doesn't Access get angry when you use a reserved word like date, for a field name and then use that field in a cfquery? Someone who uses Access might know.
    Dan Bracuk Guest

  18. #17

    Default Re: Need Help with Record Insert Error

    Ahhh yes, reserved words, good point! I should have tripped over the obvious on the way to trying to provide an answer.

    Phil :o
    paross1 Guest

  19. #18

    Default Re: Need Help with Record Insert Error

    That was it. Amazing...thanks so much anyway to all of you who tried to lend a
    hand. When I get beyond my novice phase, I will come back and help others out.

    Date seems like such a logical column header - I would have thought that when
    searching on "date" or "reserved keywords" in MS Access I would see something
    about this. Then again it is the evil empire.

    Thanks again.

    manhattanmediaworks Guest

  20. #19

    Default Re: Need Help with Record Insert Error

    <a target=_blank class=ftalternatingbarlinklarge href="http://www.aspfaq.com/show.asp?id=2080

    Good">[url]http://www.aspfaq.com/show.asp?id=2080[/url]

    Good</a> resource above on reserved keywords.
    manhattanmediaworks 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