Solved

determine last record in a recordset

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now