SQL Insert Into Giving Me Error

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

  1. #1

    Default SQL Insert Into Giving Me Error

    I am trying to insert a record into an access database using a flash form on
    the entry page and an insert into clause on the action page. I continue to get
    an invalid insert into error. Here is my SQL code: Underneath the code I have
    the cfoutput of the form fields on to a test page.

    <cfquery datasource="Users">
    INSERT INTO Users_1 (UserName, Password, Email, Phone, City, State,
    Address, Zip, Building_Num, PriceHi, PriceLo, Bed, Bath, Acreage, City_Search,
    PropertyType, View, Frontage)
    VALUES (
    <cfif IsDefined("FORM.Username") AND #FORM.Username# NEQ
    "">'#Form.Username#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Password") AND #FORM.Password# NEQ
    "">'#Form.Password#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Email") AND #FORM.Email# NEQ
    "">'#Form.Email#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Phone") AND #FORM.Phone# NEQ
    "">'#Form.Phone#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.City") AND #FORM.City# NEQ
    "">'#Form.City#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.State") AND #FORM.State# NEQ
    "">'#Form.State#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Address") AND #FORM.Address# NEQ
    "">'#Form.Address#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Zip") AND #FORM.Zip# NEQ
    "">#Form.Zip#<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Building_Num") AND #FORM.Building_Num# NEQ
    "">'#Form.Building_Num#'<cfelse>, NULL</cfif>,
    <cfif IsDefined("FORM.PriceHi") AND #FORM.PriceHi# NEQ
    "">#Form.PriceHi#<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.PriceLo") AND #FORM.PriceLo# NEQ
    "">#Form.PriceLo#<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Bed") AND #FORM.Bed# NEQ
    "">#Form.Bed#<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Bath") AND #FORM.Bath# NEQ
    "">#Form.Bath#<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Acreage") AND #FORM.Acreage# NEQ
    "">#Form.Acreage#<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.City_Search") AND #FORM.City_Search# NEQ
    "">'#Form.City_Search#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.PropertyType") AND #FORM.PropertyType# NEQ
    "">'#Form.PropertyType#'<Cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.View") AND #FORM.View# NEQ
    "">'#Form.View#'<cfelse>NULL</cfif>,
    <cfif IsDefined("FORM.Frontage") AND #FORM.Frontage# NEQ
    "">'#Form.Frontage#'<cfelse>NULL</cfif>)
    </cfquery>

    Cfoutput of same code on test page is:
    'Username', NULL, 'Email', 'Phone', 'City', 'ST', 'Address', Zip, 'Bldg',
    999999999, 0, 0, 0, NULL, NULL, NULL, NULL, NULL

    I don't see why this is not a valid insert clause. Any help would be much
    appreciated.Text

    Johnny Derk Guest

  2. Similar Questions and Discussions

    1. Creation of triggers using <CFQUERY> tag is giving error
      Hi, I am creating triggers and stored procedure on ORACLE data base using <CFQUERY>. <CFQUERY DATASOURCE="CRM"> create or replace trigger...
    2. Insert giving message on server but not locally
      I am getting the following error when I try to insert a record into my database on the server: Error Executing Database Query. Syntax error in...
    3. Output giving VERY ODD error, won't work (CFP
      Why won't this work? All the datatypes are correct, and in the CORRECT order. It seems to be hanging up on the OUT parameter at the end It gives...
    4. INSERT statement giving me no love
      Hi, I've been trying to input data into an access database for a while now, but have had nothing but frustrating errors. I finally figured out...
    5. COM+ component giving wierd error in WebService
      I had this working once apon a time before my code was obliterated.... This is a simple dll hosted on a server that goes to a database and returns...
  3. #2

    Default Re: SQL Insert Into Giving Me Error

    You need a closing ) after your last </CFIF>
    jdeline Guest

  4. #3

    Default Re: SQL Insert Into Giving Me Error

    I have it in my code. Somehow that ")" turned into that smily face at the end
    of my coded when I submitted it. User error I geuss. Thank You for your reply,
    If you have any other suggestions please let me know.

    Johnny Derk Guest

  5. #4

    Default Re: SQL Insert Into Giving Me Error

    Suggestion number 1, not related to your problem, is to make zip code a
    character field rather than numeric. Otherwise you will have issues with
    leading zeros 10 character zip codes.

    To solve your problem, comment out fields 2 through 17 and attempt to insert a
    record with just a username. Add one field at a time until it crashes, then
    you'll know where your problem is.

    Dan Bracuk Guest

  6. #5

    Default Re: SQL Insert Into Giving Me Error

    Dan,

    Thank you. Took Your advise, Found that the field names were conflicting with
    the access reserved words. Just need to be more careful with my naming
    convention. Also, Thank You for the tip on the Zip field. I will make that
    change.

    Johnny Derk 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