Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 11th, 2004, 02:24 PM
Authorized User
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exception occured.

Hi guys,

I want to retrieve results from a table. The result is fine, but I keep getting the following message:

error '80020009'
Exception occurred.

/pr/OC_fair/index.asp, line 80

Here is the code in the page:

66. <%
67. set rs2=server.CreateObject("adodb.recordset")
68. rs2.open "SELECT * FROM dbo.OC_fair_query", MM_conn_STRING,1,3
69. %>
71. <% If rs2.EOF And rs2.BOF Then %>
72. There is no registration yet.
73. <% Response.end %>
74. <% End If %>
75. <%
76. dim i
77. i = 1
78. While Not rs2.EOF %>
79. <div align="center"><%= rs2("cat") %></div>
80. <% While rs2("catID") = i%>

<div align="center"><%= rs2("staff") %></div>
<% rs2.movenext
  i = i + 1

Any help would be appreciated!


Old June 11th, 2004, 07:13 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts


I think this may be causing you problems because you are reaching the end and querying a value, which would be null. by doing another while, you can burn through many records without checking for EOF.

Old June 11th, 2004, 10:08 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

Hi Cindrella,

That is because, you would reach EOF in your INNER WHILE, as you use MOVENEXT there, but you check for recordset EOF only in the OUTER WHILE, and unless the CATID changes, it will vener EXIT from the INNER WHILE, by then you reach EOF there.

How many WHILE constructs you want to use for a recordset?
Post here on what you are trying to achieve, so that we may rephrase your code in a better way to work without problems.

Looks like you want to CAT-wise list the STAFF.



and so on...???

If so try this

set rs2=server.CreateObject("adodb.recordset")
rs2.open "SELECT * FROM dbo.OC_fair_query Order by Cat", MM_conn_STRING,1,3

If rs2.EOF And rs2.BOF Then
   'There is no registration yet.
End If

dim CatVal

While Not rs2.EOF
   If rs2("cat")<>CatVal then
      Response.write "<div align='center'>" & rs2("cat") & "</div>"
   End If
   Response.write "<div align='center'>" & rs2("staff") & "</div>"
Code in blue are the new changes need to be done.

Also try to keep the ASP server tags <% %> to minimal count for faster performance and more readablity.

Hope that helps.

-Vijay G
Strive for Perfection
Old June 14th, 2004, 09:11 AM
Authorized User
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts


Thanks so much for trouble shooting my code! Once again your solutioin worked like magic for me!

- Brian,

Thanks a lot for your help, too! I really appreciate it!


Old February 9th, 2005, 12:49 PM
Registered User
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Just came to this site today. Will have to come back for more! Thanks happygv, I had the same problem and your code helped tremendously!! :D

Similar Threads
Thread Thread Starter Forum Replies Last Post
Type mimatch & Exception Occured Error Sameer Kulkarni Classic ASP Professional 4 March 9th, 2006 05:41 AM
An unidentified error has occured p2ptolu MySQL 0 October 28th, 2005 07:40 AM
Exception Occured (0x80020009) problem dominic_huang Classic ASP Databases 1 November 17th, 2004 01:13 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.