Trouble inserting date into database

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

  1. #1

    Default Trouble inserting date into database

    The date format in the form being submitted is mm/dd/yyyy.
    Below is the error I'm getting.
    Any help would make me really happy!
    Thanks

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Too few parameters. Expected 2.

    Error occurs in line 42

    40 : '#Trim(FORM.Frequency)#',
    41 : #FORM.FrequencyUnitsID#,
    42 : #CreateODBCDate(FORM.DateTaken)#)
    43 : </cfquery>
    :o

    cshow365 Guest

  2. Similar Questions and Discussions

    1. Trouble Inserting Page Spreads
      I always have a real hard time inserting page spreads into a document. What am I doing wrong? Say I have a 20 page magazine document. If I want to...
    2. inserting date into MySql Database
      I am trying to insert the current date into a MySql database. I know that the date format for MySql is yyyy-mm-dd . So far I have tried to insert...
    3. Trouble inserting data in database
      I use DW 2004, XP with sp2, and Access 2003. Im planning to make a site that is possible to log in and update news from the web. So I have made a...
    4. Inserting Current Date into MySQL Database
      OK, I am a complete Newbie at this, well... almost... I am creating a database that accepts members. I need to know how to insert the date of...
    5. inserting the current date into mysql database fild
      Hi I'm using DW MX and the php_mysql server model I have generated this code for inserting data into the DB. <code> if...
  3. #2

    Default Re: Trouble inserting date into database

    Can you post the query code and the actual sql statement sent to the database from the error message (it contains the actual values submitted).
    mxstu Guest

  4. #3

    Default Re: Trouble inserting date into database

    Here it is!

    <cfquery datasource="#APPLICATION.dataSource#">
    INSERT INTO Drugs(UserID,
    DrugName,
    Dose,
    DoseUnits,
    Frequency,
    FrequencyUnitsID,
    DateTaken)
    VALUES(#SESSION.auth.UserID#,
    #FORM.DrugName#,
    '#Trim(FORM.Dose)#',
    #FORM.DoseUnits#,
    '#Trim(FORM.Frequency)#',
    #FORM.FrequencyUnitsID#,
    #CreateODBCDate(DateTaken)#)
    </cfquery>




    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Too few parameters. Expected 2.

    The error occurred in C:\CFusionMX7\wwwroot\Project
    Alpha\drugs091805\drug_insert1.cfm: line 42

    40 : '#Trim(FORM.Frequency)#',
    41 : #FORM.FrequencyUnitsID#,
    42 : #CreateODBCDate(DateTaken)#)
    43 : </cfquery>
    44 :


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

    SQL INSERT INTO Drugs(UserID, DrugName, Dose, DoseUnits, Frequency,
    FrequencyUnitsID, DateTaken) VALUES(3, DRUG1, '2', mg, '2', 1, {d
    '2005-09-18'})
    DATASOURCE Drugs
    VENDORERRORCODE -3010
    SQLSTATE 07002


    cshow365 Guest

  5. #4

    Default Re: Trouble inserting date into database

    I don't think the problem is the date. I think you are just missing single
    quotes around some of the form values. If you are inserting into a "text"
    column, you must use single quotes. If it is a "numeric" column then you do
    not need single quotes.

    VALUES(3, DRUG1, '2', mg, '2', 1, {d '2005-09-18'})

    mxstu Guest

  6. #5

    Default Re: Trouble inserting date into database

    A million times thank you!
    cshow365 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