Question

asp/vbscipt

Asked by: StevenJames

   strQuery = "Select * From Details Where UserID='" & strUserID &"'"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open strConnect
    rs.Open strQuery, conn, adOpenForwardOnly, adLockOptimistic, adCmdText

If strUserID exists then the open operation works fine and I can get the details and paint the screen. But if strUserID does NOT exist, I get:

Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/User/staff.asp, line 101

Any idea what I'm doing wrong?


sorry. only have 30 pts:(

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-07-05 at 15:34:13ID24545265
Tags

vbs bof error asp

Topics

Active Server Pages (ASP)

,

Scripting Languages

Participating Experts
3
Points
30
Comments
13

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. An exception occurred: 'RS.open'
    sometimes, this error will occurred on and off. but, sometimes it is working perfectly, no error! does anyone know y is it so? Error Type: Microsoft VBScript runtime (0x800A01FB) An exception occurred: 'RS.open' /alai/backoffice/product/product.asp, line 119 thanks
  2. rs.open syntax
    What is the syntax for the following command rs.open I have tried rs.open "SELECT * FROM jobs" but is still says it is incorect! Any help would be appreciated!
  3. Error Handling for Conn.Open ConnectionString
    Hi there everyone, I have a database server thats being flaky, and I want to be able to know if it goes down. For the .asp page that creates my search page, I have an include file, pasted below. I want to have it email me if the connection is not made for some reason, then go...
  4. .EOF trouble
    I'm trying to do a simple end of file check on a query that I'm running and if it comes back true I append information from the previous form (if there is any) into the Mileage table. However, the .eof seems to be locking up the server and causing it to time out. I get this...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: chilternPCPosted on 2009-07-05 at 16:02:50ID: 24781625

30 points?
the error message is correct - you must design the test to catch that reposnce

 

by: StevenJamesPosted on 2009-07-05 at 16:09:24ID: 24781642

lol. trying to answer a few questions now to make it worth while. I'm soooo broke. lol.

On topic: I can't open the recordset to check if there are any because it dies if there are none!

 

by: StevenJamesPosted on 2009-07-05 at 16:10:47ID: 24781646

Note that I'm not trying to retrieve a record that isn't there, it throws the error if the passed userid doesn't exist. (if it does, it opens fine and call pull the data.)

 

by: StevenJamesPosted on 2009-07-05 at 16:12:50ID: 24781653

userid   details
1            abc
3            cde
4            rtd

If I use
strQuery = "Select * From Details Where UserID='2'
it won't open and the error is thrown.

 

by: leewPosted on 2009-07-05 at 16:37:38ID: 24781697

Where are you setting the value of "strUserID" ?  Because you basically need to do an error check to ENSURE that it has a value and if you can't then you need to enclose your database request in an IF that checks that strUserID is set.

 

by: StevenJamesPosted on 2009-07-05 at 16:55:08ID: 24781737

Of course it's there.

If I do: (where 4 IS in the database)
strQuery = "Select * From Details Where UserID="4"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open strConnect
    rs.Open strQuery, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
I can can get the details with rs("details")

If I do: (where 2 IS NOT in the database)
strQuery = "Select * From Details Where UserID='" & strUserID &"2"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open strConnect
    rs.Open strQuery, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
The rs.open dies with the error.

 

by: leewPosted on 2009-07-05 at 16:59:41ID: 24781745

So, what's in the strUserID variable?  Have you output it to the screen?  That's how you debug - find out what the variable says!

strQuery = "Select * From Details Where UserID='" & strUserID & "2"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open strConnect
    'Assuming this is ASP on a web page
    Response.Write "<br>strQuery = [" & strQuery & "]<br>strUserID= [" & strUserID & "]<br>"
    rs.Open strQuery, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: StevenJamesPosted on 2009-07-05 at 17:58:42ID: 24781871

If I request where UserID is 4 (or any other that IS IN the database) I can paint the details to to screen. BUT if UserID is 2 (is NOT in the table) I get an error trying to open the table/recordset.

strQuery = "Select * From Details Where UserID="2"
rs.Open strQuery, conn, adOpenForwardOnly, adLockOptimistic, adCmdText
produces this error:
<b>
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/User/staff.asp, line 101
</b>

 

by: carrzkissPosted on 2009-07-05 at 22:48:26ID: 24782853

It is in your first record.
You have to see if there is any record existing, if not then show message.

<%if not rs.eof then%>
<%=rs("Userid")%>
<%
else
response.Write"That ID Does not exist in our database"
end if%>

Good Luck
Carrzkiss

 

by: StevenJamesPosted on 2009-07-06 at 07:31:00ID: 24785534

After spending all night trying to figure this out, I uninstalled/reinstalled visual studio this morning. Seems like some components were messed up (ADODB?) because reinstalling seems to have fixed it.

I wasn't trying to look at a record that didn't exist. I couldn't open an EMPTY recordset. Checking for bof or eof wasn't possible because it would error out in the attempt to simply open an empty recordset.

This is an intuitive shot in the dark at the cause: I suspect this may be an obscure bug in the adOpenForwardOnly parameter because in some cases, you can get a recordcount without a movelast in Access Basic, that means it may be looking ahead when the recordset opens. Since I have both Office 2007 and Access 2003 loaded, maybe it created an issue. But for all I know... it could be something as simple as the alignment of the moon and mars with pluto.

 

by: chilternPCPosted on 2009-07-06 at 07:54:56ID: 24785767

me thinks you don't want to give away your points :-)
I belive the solution suggested by carrzkiss has solved the problem

 

by: carrzkissPosted on 2009-07-06 at 11:28:56ID: 24787863

Steven.
I created a Database. And then added in some entries. TO TEST
What I provided here BEFORE I provided it here.
I got the same exact error as you got, on the same blasted line.
And then I added in the code that I provided above, and it fixed the issue.

When you get the EOF BOF errors
You first and foremost want to look at if the record exist.
And if it does-not, then do something about it. You want to stop it from processing.
And in this case, I stopped it by using the
If not rs.EOF then

This fixed the issue in my demo, it would fix yours as well.
If you do not want to learn how to trouble shot your code then you need to find another way to do your coding.

Carrzkiss

 

by: StevenJamesPosted on 2009-07-14 at 19:42:22ID: 24855926

carrzkiss,

I've been doing this since 1992, so I know how to open a recordset. lol.

Of course you have to check to see if there are any records in the recordset (if rs.bof or rs.eof is true then it's empty) before you look at it via an assignment statement like strVar=rs("field")

HOWEVER, and this is where everyone is getting lost.

To look at EOF and BOF you must OPEN the recordset with
rs.Open strQuery ... (ok so far)

If the record in the WHERE clause exists then I can check EOF and BOF. No problem

BUT.... and here's the really important part!!!!!

If the record is not found (doesn't exist) in the table, as in my example above, then I was getting the error AS the recordset was open.
Right at the rs.Open strQuery ... line.
So checking BOF or EOF is impossible at this point. You actually have to get to the If rs.BOF or rs.EOF BREAKPOINT to check if records exist.
...

BTW, I use visual studio and attach the process to debug so I don't have to use response.write for too much.

Hope that clears it up.

Thanks.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...