?
Solved

determine last record in a recordset

Posted on 2011-09-28
5
Medium Priority
?
241 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

862 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