It is marginally faster to perform recordset element lookups by ordinal position (e.g. rs(0) or rs(0).value) vs name (e.g. rs("column_name")).
Now, it might be difficult to keep track of name->ordinal pairs when dealing with larger resultsets. There is definitely a trade-off for maintainability... but as long as you control the order of the elements (by avoiding SELECT *, which you shouldn't be using anyway—see
Article #2096), you should be able to stay on top of it. To make the transition easier, you should insert a little key for yourself when generating a resultset, such as the following:
<% set conn = CreateObject("ADODB.Connection") conn.open "<connection string>" set rs = conn.execute("EXEC dbo.GetAuthors") if not rs.eof then do while not rs.eof id = rs(0) ' SELECT ID, fname = rs(1) ' fname, lname = rs(2) ' lname FROM table ' ... process results using local vars rs.movenext loop end if rs.close set rs = nothing conn.close set conn = nothing %> |
The only danger here is when somebody changes the order of columns in the SELECT list for the SQL statement or stored procedure.
Now, an even better way is to use GetRows() or GetString() (see
Article #2467). But speaking from experience, I know it is tough to teach an old dog new tricks, and you can't just suddenly convert all your code to use those methods. I believe that GetRows() / GetString() are much faster than either option above, but I find the development cycles are much longer because I haven't yet bothered to memorize the syntax.