"Item not found" error

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default "Item not found" error

    How do I get around the recordset error "Item not found" due to a field not
    being listed? I run several queries according to what the user selects, and
    some of those queries don't always contain the same fields, but the template
    for the output is the same, so I would like to say something to the effect
    of
    "if rs(f1) doesn't exist, do this " but how?

    I have tried If isempty(rs("f1")) which works for if a recordset exists, but
    doesn't work for if an item in the recordset exists.

    Thanks for your help.



    eagletender Guest

  2. Similar Questions and Discussions

    1. "File not found" Error Linux - cfm pages work in adminonly
      Hello all. Just installed new 6.1 install w/ Apache 2.0.52 and New Version of Redhat. The admin loads just fine, but in any of the sites it throws...
    2. No default member found for type "myClass" error, please help
      Hi, I have a collection object that I created that inherits from ArrayList. I then add "Programme" objects to this collection and bind it to the...
    3. "There was an error opening this document. This file cannot be found."
      Myself and a co-worker get this error when attempting to open an Adobe PDF directly from the SQL Reporting Services package EXPORT feature. If we...
    4. Field name is valid, but getting an "Item cannot be found.." error
      The field name 'articleid', which is an identity/primary key , is not being recognized in my recordset as I get an " Item cannot be found in the...
    5. make hangs on "libz.la" not found error
      Hello I hope someone out there can help explain this to me. This afternoon I successfully compiled php4.3.3 with a given set of configuration...
  3. #2

    Default Re: "Item not found" error

    You could trap the error, and check if the error is of type "Item not found"

    ' Ask the compiler to run despite error
    On Error Resume Next

    ' Do operations on your recordset
    Rs("MyField") ... etc.

    ' If an error occurs due to the operation, check to see if it
    ' happened due to the fact a column was missing
    If Err.Number <> 0 Then
    If Err.Description = "<type the exact error desc here>" Then
    Handle the error in this block
    End If
    End If


    --
    Manohar Kamath
    Editor, .netWire
    [url]www.dotnetwire.com[/url]


    "eagletender" <eagletender2001@yahoo.com> wrote in message
    news:lmxrc.720$OV.68159@news.uswest.net...
    > How do I get around the recordset error "Item not found" due to a field
    not
    > being listed? I run several queries according to what the user selects,
    and
    > some of those queries don't always contain the same fields, but the
    template
    > for the output is the same, so I would like to say something to the effect
    > of
    > "if rs(f1) doesn't exist, do this " but how?
    >
    > I have tried If isempty(rs("f1")) which works for if a recordset exists,
    but
    > doesn't work for if an item in the recordset exists.
    >
    > Thanks for your help.
    >
    >
    >

    Manohar Kamath [MVP] Guest

  4. #3

    Default Re: "Item not found" error

    eagletender wrote:
    > How do I get around the recordset error "Item not found" due to a
    > field not being listed? I run several queries according to what the
    > user selects, and some of those queries don't always contain the same
    > fields, but the template for the output is the same, so I would like
    > to say something to the effect of
    > "if rs(f1) doesn't exist, do this " but how?
    >
    > I have tried If isempty(rs("f1")) which works for if a recordset
    > exists, but doesn't work for if an item in the recordset exists.
    >
    > Thanks for your help.
    A recordset object has a Fields collection, which contains Field objects. A
    Field object has a Name property. You can loop through the Fields collection
    and check each Field's Name property to verify the existence of a field
    name. I would encapsulate this into a function:

    function FieldExists(pRS, psFieldName)
    dim fld, bFound
    bFound = False
    for each fld in pRS.Fields
    if fld.Name = psFieldName then
    bFound = True
    Exit For
    end if
    next
    FieldExists = bFound
    End Function

    You would use it like this:
    If FieldExists(rs, "f1") then
    ....


    Having said that, you would probably be better off using the ordinal
    position of the fields to reference them - rs(0) ...

    HTH,
    Bob barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  5. #4

    Default Re: "Item not found" error

    Thanks, I will try both of those. The On Error Resume Next is fine, because
    if the field doesn't exist, that's okay, it just doesn't display the
    information.

    However, how do I "undo" that, because I want other errors to occur? Is
    there no way to do a On resume GOTO Label, like in VB? That might work too.

    As far as checking for a field, I have a gazilion of them, it seems like it
    might be pretty tedious and/or time consuming to run the check every time,
    no? Is it better programming procedure to run the check?



    "eagletender" <eagletender2001@yahoo.com> wrote in message
    news:lmxrc.720$OV.68159@news.uswest.net...
    > How do I get around the recordset error "Item not found" due to a field
    not
    > being listed? I run several queries according to what the user selects,
    and
    > some of those queries don't always contain the same fields, but the
    template
    > for the output is the same, so I would like to say something to the effect
    > of
    > "if rs(f1) doesn't exist, do this " but how?
    >
    > I have tried If isempty(rs("f1")) which works for if a recordset exists,
    but
    > doesn't work for if an item in the recordset exists.
    >
    > Thanks for your help.
    >
    >
    >
    >

    eagletender Guest

  6. #5

    Default Re: "Item not found" error

    eagletender wrote:
    > Thanks, I will try both of those. The On Error Resume Next is fine,
    > because if the field doesn't exist, that's okay, it just doesn't
    > display the information.
    >
    > However, how do I "undo" that, because I want other errors to occur?
    On Error Goto 0
    > Is there no way to do a On resume GOTO Label, like in VB?
    No.

    The vbscript documentation can be downloaded from this link:
    [url]http://www.microsoft.com/downloads/details.aspx?FamilyID=01592c48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en[/url]
    >
    > As far as checking for a field, I have a gazilion of them, it seems
    > like it might be pretty tedious and/or time consuming to run the
    > check every time, no? Is it better programming procedure to run the
    > check?
    Raising an error will be just as bad and may even be worse.

    I rarely refer to fields by name. I always know what fields are being
    returned to my recordsets, and what order they will be in, so I've never
    faced the issue that you are facing.

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  7. #6

    Default Re: "Item not found" error

    > As far as checking for a field, I have a gazilion of them,

    Why do you have a gazillion fields? Why isn't your query better-defined?
    If you call a query, you should know what the output looks like... you
    shouldn't need to check.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    Aaron Bertrand - MVP 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