[thelist] ASP, SQL, Recordsets, Best Practices

Michele Foster michele at wordpro.on.ca
Thu Mar 1 14:25:33 CST 2001


Ok, how's that for a subject line .. <grin>

A couple questions I have come across while updating some code on an
existing site.  Sure, it works as it exists now, but I'm trying to optimize
the code, and am wondering a few things in the process ...

(1)

When querying a unique field in a database, and the answer is either "yes a
record exists" or "no record exists", is it necessary to still loop through
the recordset?  IOW, do I need to loop through the recordset with a "do
until rs.eof" blah, blah, "rs.movenext, loop" .. when there can only be one
unique record (field doesn't allow duplicates) or no record at all.

(2)

"Should" all the fields that you need to display on the page be declared
prior to using them?

i.e.   Dim size
        size=rs("sizefromdb")
        response.write " & size & "

Or, is declaring the fields an unnecessary step, IF the field is only being
written/used once?

i.e.    response.write rs("sizefromdb")


TIA,

Michele






More information about the thelist mailing list