How to find out the records that match your requirement?
Find method can be based on some rules to find the record in the Recordset that match your requirement.
A simple example is shown below:
<%
Const adSearchBackward = 1
Set conn = Server.CreateObject("Adodb.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")
Set rs = Server.CreateObject("Adodb.Recordset")
rs.open "Member",conn,1,3
if Not rs.EOF Then
rs.MoveFirst 'Move to the first record;
rs.Find "Location = 'LA'" 'Find the first record that the location is "LA"
If rs.EOF Then 'If EOF is True; which means the record is not found!
Response.write("Record Not Found!
")
else
Response.write(rs.Fields("MemberName") & "     " & rs.Fields("Location") &"
")
End If
'you can also search from the last record
rs.MoveLast 'Move to the last record;
rs.Find "Location = 'LA'" ,, adSearchBackward 'Search backward to find the last record that the location is "LA"
If rs.BOF Then 'If BOF is True; which means the record is not found!
Response.write("Record Not Found!
")
else
Response.write(rs.Fields("MemberName") & "     " & rs.Fields("Location") &"
")
End If
End IF
rs.Close
Set rs = Nothing
%>
No comments:
Post a Comment