determine last record in a recordset

Posted on 2011-09-28
Last Modified: 2012-05-12
I am using classic ASP.

I am looping through a recordset and I need to know when I have reached the last record.  

Is there an easy way to do this?  Like say use rs.EOF -1

Question by:nickgross19
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 36720169
When I am getting data from a database I just use the microsoft tools to get the data and loop through the count that way.  Here is an example:
string SelectString = "SELECT NAME FROM PEOPLE WHERE NAME = 'Steve'";

SqlConnection SqlConnect = new SqlConnection(GetConnectString());
SqlDataAdapter da = new SqlDataAdapter(SelectString, SqlConnect);

DataSet ds = new DataSet();

DataTable dataTable = ds.Tables[0];
DataRow[] dataRow = dataTable.Select();

if (dataTable.Rows.Count > 0)
	for (int indx = 0; indx < dataTable.Rows.Count; indx++)
		string Name = dataRow[indx]["NAME"].ToString();

Open in new window


Author Comment

ID: 36720246
Can you do this stuff in classic ASP, I am not using

Expert Comment

ID: 36720334
Yes, many of the SQL classes are in ASP.  I ported this code over from an original ASP project.

Expert Comment

ID: 36720377
I also came across an example I used a few years ago about classic ASP and an Access Database.  I have attached the sources.  It is also in VB.  I used the

Do While not rsGuestbook.EOF

for testing the database records.  In the attached file I had to change the .asp files to aspx, or the website would not let me attach the zip file.  Let me know if you have any questions.
LVL 15

Accepted Solution

pateljitu earned 500 total points
ID: 36720592
Please give this script a try, not sure of what you need to achieve and example would be great, thanks:

do while not rs.EOF

if rs.EOF then response.Write("EOF true")

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Classic ASP application Will support SQL 2014 5 102
Microsoft SQL ADO Conn Issue 6 58
Time Conversions...both ways 2 24
Diminish Pop-up  in 3 seconds 7 66
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question