exception '80020009'

M

Marco

When i try to execute this cycle:

<%while not (oRS("IDFoto")=IDFoto)
IDPrec=oRS("IDFoto")
oRS.MoveNext
wend%>

i get the error:
80020009 Exception Occurred

I want to select the record with the field IDFOTO= the value in the variable
IDFoto
I'm sure the cycle doesn't work, if i modify it so:

while (oRS("IDFoto")=IDFoto)

it works (but with no right result of course)

Does anyone can help me??

Thanks

Marco
 
B

Bob Barrows

Marco said:
When i try to execute this cycle:

<%while not (oRS("IDFoto")=IDFoto)
IDPrec=oRS("IDFoto")
oRS.MoveNext
wend%>

i get the error:
80020009 Exception Occurred

I want to select the record with the field IDFOTO= the value in the
variable IDFoto
I'm sure the cycle doesn't work, if i modify it so:

while (oRS("IDFoto")=IDFoto)

it works (but with no right result of course)

Does anyone can help me??

Thanks

Marco

Why are you using a loop to find a record? Finding records is what queries
were designed to do very efficiently. I suggest adding this search criterion
to the query that you use to open the recordset.

If for some reason you need to retrieve records in addition to the records
that meet this search criterion, then use the recordset's Find method to get
the record.

If IDFoto is a text/char field:
oRs.Find "IDFoto='" & IDFoto & "'"

If numeric:
oRs.Find "IDFoto=" & IDFoto

Here is the documentation on the Find method:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmthfindmethodado.asp

If there are multiple records that meet the criteria, use the Filter
property instead:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdprofilter.asp?frame=true

You will need to use a cursor that supports bookmarks (adOpenStatic) in
order to use these methods.

HTH,
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top