Solved

determine last record in a recordset

Posted on 2011-09-28
5
228 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
[X]
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
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select record with the most recent date 14 72
JQuery on multiple lines 3 47
SQL help please 15 35
Save data in two Database, Asp 2 68
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 demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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