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
elseif dbrs.fields("Drink").value = "Water" Then
elseif dbrs.fields("Drink").value = "Wine" Then
elseif dbrs.fields("Drink").value = "Beer" Then
   do until drunk
   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")


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