Solved

determine last record in a recordset

Posted on 2011-09-28
5
225 Views
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

Thanks
0
Comment
Question by:nickgross19
  • 3
5 Comments
 
LVL 2

Expert Comment

by:junkymail1
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();
da.Fill(ds);
SqlConnect.Close();

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

0
 

Author Comment

by:nickgross19
ID: 36720246
Can you do this stuff in classic ASP, I am not using asp.net?
0
 
LVL 2

Expert Comment

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

Expert Comment

by:junkymail1
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.
example.zip
0
 
LVL 15

Accepted Solution

by:
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
  ......

 rs.MoveNext
if rs.EOF then response.Write("EOF true")
           
loop
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to speed up an ASP/MS SQL web application 6 71
Dreamweaver server behavior gone 6 138
SP to delete duplicates 15 71
ASP CDO - Limiting Connections 2 53
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

825 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