Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple problem of Recordset!!! pl. help :(

Status
Not open for further replies.

Technos

Programmer
Mar 15, 2002
47
US
Hey There,
I stuck with a simple problem.

I need to read only last three records from my recordset.
I tested with EOF and its working fine and reading all data.

Can anybody tell how to read only last 3?

My code is
Code:
Set dbConn = CreateObject("ADODB.Connection")
dbConn.open "DSN=Career;SERVER=GETDB;UID=career;PWD=mycareer;DATABASE=career"   
strSQL = "Select * from Careers where show=1 and homeb='H'"
set rs = dbConn.Execute(strSQL)

if not rs.eof then%>

        <ul>
          <% do while not rs.eof %>
          <li><a href=&quot;<%response.write &quot;positions/&quot; & rs(&quot;filename&quot;)%>&quot; target=&quot;_blank&quot;><%Response.write rs(&quot;Name&quot;)%></a>- 
	<%Response.write rs(&quot;Description&quot;)%><br>
          </li>
          <% rs.movenext
                loop %>
        </ul>
        <% end if %>

Thanks A Lot
Reena
 
rs.moveLast
i=1
do until i=3 %>
<li><a href=&quot;<%response.write &quot;positions/&quot; & rs(&quot;filename&quot;)%>&quot; target=&quot;_blank&quot;><%Response.write rs(&quot;Name&quot;)%></a>-
<%Response.write rs(&quot;Description&quot;)%><br>
</li>
i=i+1
<% rs.movePrevious
loop %>
</ul>
 
Hi sjravee
I got this error after doing movePrevious.

Rowset does not support fetching backward.

Can You Help.

Thanks
 
Hi,
You are right. My cursorType is set to default 0.
But now if I'm trying to change it by doing this

rs.cursorType=adOpenStatic

it gives me following error.
Operation is not allowed when the object is open.

Where/How to write this line? I'm Stuck.

Thanks
 
You need to set your cursor before opening your recordset:

rs.cursorType=adOpenStatic
set rs = dbConn.Execute(strSQL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top