Low cost ecommerce web development India flash website design
36
We shall look at the next few lines as a complete block and not as separate
lines of code.
Else
RS.MoveFirst
While Not RS.EOF
Response.Write RS.Fields (“FirstName”)
Response.Write RS.Fields (“LastName”)
Response.Write “<HR>”
ACTIVE SERVER PAGES 3.0
RS.MoveNext
Wend
End If
RS.MoveFirst is a method that moves the record pointer (for now, consider
this to be an imaginary structure that always points to the current record in
the
Recordset) to the First record. By default, it may or may not be positioned
correctly, so it is imperative to position it before you begin any operations.
Then we have a While-loop that iterates through all the records contained in
the Recordset. The condition that we check is that RS.EOF should be False.
The moment it is True, it can be inferred that there are no more records to
be
found.
RS.Fields(“FirstName”) retrieves the value of the “FirstName”
field of
the current record. We use a Response.Write statement to write it out to the
page. Similarly, we write the RS.Fields (“LastName”) after the first
name.
You may also use a shortcut syntax for this, which takes the form:
RS (”FirstName”)
After you’re done displaying, you must advance the record pointer to the
next
record, so you execute a RS.MoveNext. And that’s all you wanted to do
within
the loop, so you end the loop now. Just write Wend and the loop ends! And so
does our little example!
Freelance web designer ASP PHP ecommerce web development India