Inspired? No home

ASP Performance Best Practices #2

This is the second post in my 'ASP Performance Best Practices' series. Read the first post about using ADO GetRows() here.

General ASP script tips:

if dbrs.fields("Drink").value = "Milk" Then
   Accept(false)
elseif dbrs.fields("Drink").value = "Water" Then
   SaveForLater()
elseif dbrs.fields("Drink").value = "Wine" Then
   CheckWineLabel()
elseif dbrs.fields("Drink").value = "Beer" Then
   do until drunk
       Drink()
       GetNewBeer()
   loop
else
   response.write "Unknown liquid"
end if

Instead use:

Dim value
value = dbrs.fields("Drink").value
If value = "Milk" Then .....

 

 

querystring_value = request("var1")
recordset_value = dbrs("Fieldname")

use:

querystring_value = request.querystring.item("var1")
recordset_value = dbrs.fields.item("Fieldname").value

In some cases there will be a default property, but if not then ASP has to loop through all possible properties to find what you are looking for. In the case of the Request object, ASP has to loop through the form, querystring, cookies, clientCertificate and serverVariables collections to find the variable. With ADO Recordset I am not sure if this is relevant, I think the fields collection is the default and the property collection is ignored - but I don't know.

Written on 30 September 2004.
blog comments powered by Disqus