CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • ADODB.Recordset (0x800A0CC1) Item cannot be found in the collection corresponding to the requested name or ordinal.

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    29
  • Date Created
    Thursday, October 7, 2010
  • Last Updated
    Thursday, January 19, 2023
  • This Article Has been Viewed
    2916 times
  • Short Desc
    Misspelled SQL Columns names in your recordset will cause an error; ensure all columns are spelled correctly and are present in your SQL Statement before calling them to be used in your RecordSet.
  • Details
    When creating a recordset to go with your SQL Statement, sometimes you might misspell a fieldname, this happens more often then one might imagine, especially with larger data sets.

     
    ADODB.Recordset (0x800A0CC1)
    Item cannot be found in the collection corresponding to the requested name or ordinal.
    page.asp, line 37
  • Recreate Issue
    Let's look at the following SQL Statement
    Scenario #1
    <%
    sql.commandtext="select column1, column2 from table1 where column1='something'"
    set rs = sql.execute
    %>


    The above is our SQL Statement and our RecordSet.

    <%
    =rs("column3")
    %>


    The recordset we just created above will appear to be accurate, except that column3 does not exist in our SQL Statement and, therefore, will make the 800A0CC1 error.

    Scenario #2
    <%

    Set sql = CreateObject("ADODB.Command")
    sql.ActiveConnection=siteconn
    sql.Prepared = true
    sql.commandtext="select column1, column2 from table1 where column1='something'"
    set rs = sqlone.execute

    %>

    In this code, we notice the sqlone does not match the sql.commandtext
  • Resolve Issue
    Scenario #1
    We will need to make sure that all columns are added to our SQL Statement before writing our recordsets for them.

    <%
    sql.commandtext="select column1, column2, column3 from table1 where column1='something'"
    set rs = sql.execute
    %>


    The above is our SQL Statement and our RecordSet.

    <%
    =rs("column3")
    %>


    The above will run now without an issue, as we have column3 in our SQL Statement and have it spelled out correctly for our recordset to display its content.

    Scenario #2
    <%

    Set sql = CreateObject("ADODB.Command")
    sql.ActiveConnection=siteconn
    sql.Prepared = true
    sql.commandtext="select column1, column2 from table1 where column1='something'"
    set rs = sql.execute

    %>

    Make sure the sql.execute matches the sql.commandtext.