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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning a specific record

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
I have got a recordset with multiple entries in it, I want to be able to display a specific record range from this recordset (say records 5 - 10) I don't really know where to start with this at the moment being fairly new to ASP, any ideas ??
 
i hope u stored ur recordset in a object.

if u know the specific record's any one fields value for example if one of ur field name is emp_name and u want the employee with name "arperry".
if u want to cull out the particular record from the table means u can directly use the sql query for that.

like this
set myconn=server.CreateObject("adodb.connection")
myconn.Open dsn
set rs=server.CreateObject("adodb.recordset")
sql="select * from employee where emp_name='arperry'"
rs.Open sql,myconn

so that u can directly get ur specific record from ur table.

if this is not suitable for ur job means try this


set myconn=server.CreateObject("adodb.connection")
myconn.Open dsn
set rs=server.CreateObject("adodb.recordset")
sql="select * from employee"
rs.Open sql,myconn

while not rs.EOF
if rs("emp_name")="arperry' then
' print ur record
'do ur process
end if
rs.MoveNext
wend


i hope this will help u to solve ur problem
webspy
 
maybe i should have been more specific. what i want to do is to have a load of records that i can then jump through 10 at a time, at the click of a button, allowing me to move through the records in a controlled manor, as i only want to display a few recirds on a page.

so i can do something like:

i=0
end =5
while not rs.eof
response.write rs("name")(i)
i=i+1
if i >= end then
exit while
end if
rs.movenext
wend

where i is the recordcounter for the records that i want to display, and end is the final record i want to display this time around

allowing me to display the five or whatever records to the screen. can this be done in this manor, or do i have to look at another way of doing this. any suggestions ?
 
Assuming your record set name to be rs, the following will print records from 5 to 10.

rs.Move 5
Do while not rs.EOF and rs.RecordCount <= 10
rs.Fields(&quot;column1&quot;)
rs.MoveNext
Loop


Replace column1 with the frist field in your record set.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top