Ask a Question related to ASP Database, Design and Development.
-
eagletender #1
"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
-
"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... -
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... -
"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... -
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... -
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... -
Manohar Kamath [MVP] #2
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...not> How do I get around the recordset error "Item not found" due to a fieldand> being listed? I run several queries according to what the user selects,template> some of those queries don't always contain the same fields, but thebut> 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,> doesn't work for if an item in the recordset exists.
>
> Thanks for your help.
>
>
>
Manohar Kamath [MVP] Guest
-
Bob Barrows [MVP] #3
Re: "Item not found" error
eagletender wrote:
A recordset object has a Fields collection, which contains Field objects. A> 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.
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
-
eagletender #4
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...not> How do I get around the recordset error "Item not found" due to a fieldand> being listed? I run several queries according to what the user selects,template> some of those queries don't always contain the same fields, but thebut> 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,> doesn't work for if an item in the recordset exists.
>
> Thanks for your help.
>
>
>
>
eagletender Guest
-
Bob Barrows [MVP] #5
Re: "Item not found" error
eagletender wrote:
On Error Goto 0> 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?
No.> Is there no way to do a On resume GOTO Label, like in VB?
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]
Raising an error will be just as bad and may even be worse.>
> 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?
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
-
Aaron Bertrand - MVP #6
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



Reply With Quote

