Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP 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 August 12th, 2005, 05:09 AM
Registered User
 
Join Date: Jul 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADODB.Field error '80020009'

I'm trying to get the right code so that only the 5 latest additions to my db are displayed, and displayed in descending order (last in, first out). I'm very new to this and have no real idea as to why it isn't working. I'm running PWS on win98se. The code is listed below:

Code:
<%
'Dimension variables
Dim adoCon         'Holds the Database Connection Object
Dim rsNews         'Holds the recordset for the records in the database
Dim strSQL          'Holds the SQL query to query the database
Dim iRowCounter

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/rafpnews.mdb")

'Create an ADO recordset object
Set rsNews = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM tblNews order by NewsID desc;"

'Open the recordset with the SQL query
rsNews.Open strSQL, adoCon

'Loop through the recordset
Do While not rsNews.EOF

     'Write the HTML to display the current record in the recordset
     for iRowCounter = 1 to 5
     Response.Write ("<br><span class='newstitle'>")
     Response.Write (rsNews("Title"))
     Response.Write ("</span><br><span class='newsdate'>")
     Response.Write (rsNews("Date"))
     Response.Write ("</span><br><span class='newstype'>")
     Response.Write (rsNews("Type"))
     Response.Write ("</span><br><span class='newstext'>")
     Response.Write (rsNews("Text"))
     Response.Write ("</span>")

     'Move to the next record in the recordset
     rsNews.MoveNext
next    
Loop

'Reset server objects
rsNews.Close
Set rsNews = Nothing
Set adoCon = Nothing
%>
Running this code displays all the records and gives me the following error msg:
 
Quote:
quote:ADODB.Field error '80020009'
Quote:

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

?
Any help will be appreciated!

etv

I drink, therefore I am.
 
Old August 15th, 2005, 05:39 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,
You are getting this error because of the following for loop:

for iRowCounter = 1 to 5

If there are less than 5 records in the database, then you wll get the error because of above loop.

instead you can create a variable outside the while loop and increment in the loop. If the value is 5 then exit from loop. Or if you get EOF then exit.

If counter = 5 or rsNews.EOF


Om Prakash
 
Old August 16th, 2005, 12:45 AM
Registered User
 
Join Date: Jul 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Aha! Thanks, that made sense. I'll give it a bash and see what happens.

I drink, therefore I am.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB.Field error '800a0bcd' - FIXED buddyz Classic ASP Databases 2 October 9th, 2006 05:52 PM
HELP PLEASE!! error '80020009' Brolin99 Classic ASP Professional 3 April 29th, 2006 02:20 AM
error '80020009' Exception occurred. hauruapai Classic ASP Basics 2 April 10th, 2006 05:05 PM





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