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. %>
70.
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
  Wend
  i = i + 1
Wend
%>

Any help would be appreciated!

Cinderella

 
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
Default

Hello,

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.

Brian
 
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
Default

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.

Cat1
STAFF1
STAFF2

CAT2
STAFF1
STAFF2
STAFF3

and so on...???

If so try this

Code:
<%
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.
   Response.end
End If

dim CatVal

While Not rs2.EOF
   If rs2("cat")<>CatVal then
      CatVal=rs2("cat")
      Response.write "<div align='center'>" & rs2("cat") & "</div>"
   End If
   Response.write "<div align='center'>" & rs2("staff") & "</div>"
  rs2.movenext
Wend 
%>
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.
Cheers!

_________________________
-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
Default

happygv,

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!

Cinderella

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

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.