Insert Record and Retrieve autonumber extension

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default Insert Record and Retrieve autonumber extension

    I followed the instructions for useage correctly:
    [url]http://www.tom-muck.com/extensions/help/insertretrieve/[/url]

    Unfortunately it is producing the error below:

    ADODB.Recordset (0x800A0CC1)
    Item cannot be found in the collection corresponding to the requested name or
    ordinal.
    /addRisk2.asp, line 81

    Line 81 is the second line of the following excerpt:

    if Len(TM_fields(i+1)) > 0 AND TM_fields(i+1)<> "''" then
    TM_editCmd.Fields(TM_columns(i)) = TM_fields(i+1)

    I am not entirely sure what I am looking for as I only have a tiny
    understanding.....

    here is the code before the body in its entirety

    <%
    ' *** declare variables
    TM_editAction = CStr(Request("URL"))
    If (Request.QueryString <> "") Then
    TM_editAction = TM_editAction & "?" & Request.QueryString
    End If
    ' boolean to abort record edit
    TM_abortEdit = false
    %>
    <%
    ' *** Insert Record and retrieve autonumber: set variables
    If (CStr(Request("TM_insert")) <> "") Then
    MM_editConnection = MM_conRisk_STRING
    TM_editTable = "[Risk Unit]"
    TM_editRedirectUrl = "managerConfirmAddRisk.asp"
    TM_fieldsStr = "RiskDesc|value|Severity|value|Likelihood|value|Or iginator
    (Authorised)|value|Date Risk Entered|value|Date risk score
    changed|value|TM_insert|value"
    TM_columnsStr =
    "RiskDesc|',none,''|Severity|none,none,NULL|Likeli hood|none,none,NULL|[Originato
    r (Authorised)]|',none,''|[Date Risk Entered]|',none,NULL|[Date risk score
    changed]|',none,NULL|[RID Unit]|none,none,NULL"
    ' create the TM_fields and TM_columns arrays
    TM_fields = Split(TM_fieldsStr, "|")
    TM_columns = Split(TM_columnsStr, "|")
    ' set the form values
    For i = LBound(TM_fields) To UBound(TM_fields) Step 2
    TM_fields(i+1) = CStr(Request.Form(TM_fields(i)))
    Next

    ' append the query string to the redirect URL
    If (TM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, TM_editRedirectUrl, "?", vbTextCompare) = 0 And
    Request.QueryString <> "") Then
    TM_editRedirectUrl = TM_editRedirectUrl & "?" & Request.QueryString
    Else
    TM_editRedirectUrl = TM_editRedirectUrl & "&" & Request.QueryString
    End If
    End If
    TM_dontClose = false
    Else
    TM_dontClose = true
    End If
    %>
    <%
    ' *** Insert Record and retrieve autonumber for MS Access
    ' *** ID value is stored in the TM_editCmd("youridcolumn") value
    If (CStr(Request("TM_insert")) <> "") Then
    ' create the sql insert statement
    TM_tableValues = ""
    TM_dbValues = ""
    For i = LBound(TM_fields) To UBound(TM_fields) Step 2
    FormVal = TM_fields(i+1)
    TM_typeArray = Split(TM_columns(i+1),",")
    Delim = TM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = TM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = TM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    if (EmptyVal = "NULL") then EmptyVal = ""
    If (FormVal = "") Then
    FormVal = EmptyVal
    Else
    If (AltVal <> "") Then
    FormVal = AltVal
    End If
    End If
    TM_fields(i+1) = FormVal
    Next
    If (Not TM_abortEdit) Then
    ' execute the insert using the AddNew method
    set TM_editCmd = Server.CreateObject("ADODB.Recordset")
    TM_editCmd.ActiveConnection = MM_editConnection
    TM_editCmd.CursorType = 1
    TM_editCmd.LockType = 3
    TM_editCmd.Source = TM_editTable
    TM_editCmd.Open
    TM_editCmd.AddNew
    For i = LBound(TM_fields) To UBound(TM_fields) Step 2
    'If a value for the column name was passed in,
    'set the column name equal to the value passed through the form...
    if Len(TM_fields(i+1)) > 0 AND TM_fields(i+1)<> "''" then
    TM_editCmd.Fields(TM_columns(i)) = TM_fields(i+1)
    end if
    Next
    TM_editCmd.Update
    Session("myID") = TM_editCmd("RID Unit")
    If (TM_editRedirectUrl <> "") Then
    TM_editCmd.ActiveConnection.Close
    Response.Redirect(TM_editRedirectUrl)
    End If
    End If
    End If
    %>

    any help would be greatly appreciated.
    kind regards
    Emma Gale


    galeemma Guest

  2. Similar Questions and Discussions

    1. Insert and Retrieve binary objects with MS-SQL 2000
      Alrighty then, I have searched the web abd CF forums for the past 2 months trying to find a code snippet for inserting a binary object into a...
    2. How can i retrieve record ONLY From 300 - 400 in amillion Record Table?
      HI all Thanks for your time.. I have a question here.. How can i retrieve record ONLY From XXX - XXX in a million Record Table? eg. I have a...
    3. Insert record
      Hi all, I'm having a bit of a problem at the moment. I'm basically trying to insert a record to a MS Access database. I'm using dreamweaver MX. What...
    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. Grabbing an autonumber value after Insert Into....
      What database are you using?, different databases will require varied techniques. "Les Juby" <webpro@webpro.co.za> wrote in message...
  3. #2

    Default Re: Insert Record and Retrieve autonumber extension

    galeemma wrote:
    > I followed the instructions for useage correctly:
    > [url]http://www.tom-muck.com/extensions/help/insertretrieve/[/url]
    >
    > Unfortunately it is producing the error below:
    >
    > ADODB.Recordset (0x800A0CC1)
    > Item cannot be found in the collection corresponding to the requested name or
    > ordinal.
    > /addRisk2.asp, line 81
    What that error tells me is that you are trying to insert into a column
    name that isn't present in the database. I'd check to make sure that
    your field names in the page within the form and the database column
    names match up.


    --
    Danilo Celic
    | Extending Knowledge, Daily [url]http://CommunityMX.com/[/url]
    danilocelic *TMM* Guest

  4. #3

    Default Re: Insert Record and Retrieve autonumber extension

    "galeemma" <webforumsuser@macromedia.com> wrote in message
    news:d48efl$co4$1@forums.macromedia.com...
    > I followed the instructions for useage correctly:
    > [url]http://www.tom-muck.com/extensions/help/insertretrieve/[/url]
    Make sure your field names don't contain special characters (letters,
    number. underscores only), and also try to eliminate spaces if at all
    possible. Many times the database software will allow you to name things
    improperly.

    Tom


    Tom Muck 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