access relationships and coldfusion

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

  1. #1

    Default access relationships and coldfusion

    Hi guys, right a little help please.....I'm now a lot further on than last time
    I posted on here, your help the first time around was very good :)

    My Access database is now a relational one, with two tables dRegDetails and
    dSubscriptionDetails, with the primary key of the former being an AutoNumber,
    and another primary key of the latter also being an AutoNumber. To form the
    relationship between the two tables I then also have the primary key from the
    first table as a foreign key in the second table, with an equal join type -
    this foreign key field is of a Number data type, not AutoNumber (as far as I'm
    aware can't insert data into an autonumber - it gets generated automatically).
    The only real need for this foreign key is to identify related records with the
    first table.

    All fine and seems to work in Access. Now come to submitting my form data, and
    ColdFusion returns the below error. I presume it's because an AutoNumber data
    type is a complex one (not sure which one though?) and obviously a Number is a
    simple value. The CF documentation says it can't convert complex to simple
    data types - but was wondering if I can extract the value of the complex
    datatype and insert it into a new variable as a simple datatype???

    The code : (dID is the primary key in the first table)

    <cfquery datasource="cfukdoorstaff" name="pKey2fKey">
    SELECT dID FROM dRegDetails
    WHERE dEmail = '#FORM.dEmail#'
    </cfquery>
    <cfquery datasource="cfukdoorstaff" name="insertSubDetails">
    INSERT INTO dSubscriptionDetails (dID, dInitialDateReg)
    VALUES (
    '#pKey2fKey#'
    '#currentDate#'
    )
    </cfquery>

    The error in the browser :

    "Complex object types cannot be converted to simple values.

    The expression has requested a variable or an intermediate expression result
    as a simple value, however, the result cannot be converted to a simple value.
    Simple values are strings, numbers, boolean values, and date/time values.
    Queries, arrays, and COM objects are examples of complex values.

    The most likely cause of the error is that you are trying to use a complex
    value as a simple one. For example, you might be trying to use a query variable
    in a <CFIF> tag. This was possible in ColdFusion 2.0 but creates an error in
    later versions.

    The error occurred in
    C:\CFusionMX7\wwwroot\ukdoorstaff\InsertRegDetails NEWa.cfm: line 35

    33 : INSERT INTO dSubscriptionDetails (dID, dInitialDateReg)
    34 : VALUES (
    35 : '#pKey2fKey#'
    36 : '#currentDate#'
    37 : )

    ".

    Hope you can help me :)


    P_Roberts Guest

  2. Similar Questions and Discussions

    1. MS SQL Relationships
      i cant seem to find a visual tool ( like access ) in ms sql enterprise manger that allows me to setup relationships im sure its somewhere obvious...
    2. table relationships
      How do I programmtically get the relationships of a table?? I can get the list of columns: dtFields = conn.GetOleDbSchemaTable(OleDbSchemaGuid.,...
    3. Relationships in FMP5.5
      I recently upgraded us from FMP4.1 running peer to peer over TCP/IP using clients on win98, win2000, winxp pro. Used to work fine. Then I upgraded...
    4. Breaking Relationships
      Does anyone know of a way to "lock" relationships? If a db is related to second db on the network, and the network is down or unavailable, the...
    5. Creating relationships
      Hello, thank you for taking the time to read this, I appreciate it very much. Im creating a database the allows an individual/student to...
  3. #2

    Default Re: access relationships and coldfusion

    You probably should remove the single quotes from around the '#pKey2fKey#'
    value, since you stated that it is numeric. Also, you are missing a comma
    between your VALUES

    INSERT INTO dSubscriptionDetails (dID, dInitialDateReg)
    VALUES (#pKey2fKey#, '#currentDate#')

    Phil


    paross1 Guest

  4. #3

    Default Re: access relationships and coldfusion

    You're missing the query column name in your VALUES(...) clause. Use

    #pKey2fKey.dID#

    ... instead of just ...

    #pKey2fKey#

    That is probably what is causing the error. #pKey2fKey# is a query (ie.
    complex ) object.



    mxstu Guest

  5. #4

    Default Re: access relationships and coldfusion

    Although you could also use a single query instead of the two separate queries

    <cfquery datasource="cfukdoorstaff" name="insertSubDetails">
    INSERT INTO dSubscriptionDetails (dID, dInitialDateReg)
    SELECT dID, '#currentDate#'
    FROM dRegDetails
    WHERE dEmail = '#FORM.dEmail#'
    </cfquery>



    mxstu 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