Visiting ASP sites, forums and places like Expert Exchange, I see many examples of ASP code that will not result in good performance. I will make a list of tips on how to achieve good performance. These tips will include ASP (VBScript) coding techniques, SQL query/ADO/SQL Server optimization and alternative ways of doing things (XML, JavaScript on the client, DTS on SQL Server etc.). I am not a performance guru but experience and reading many articles with performance tips I have a good knowledge regarding this. If you have any better solutions than the tips here or if anything is not correct, please let me know.
Dim db, dbrs, sql, ConnString, users, user
ConnString = "DSN=YourDSN;"
sql = "SELECT UserId, Username FROM Users ORDER BY Username;"
' GET DATA
set db = server.createobject("ADODB.Connection")
db.open ConnString
set dbrs = server.createObject("ADODB.Recordset")
dbrs.open sql, db
if NOT dbrs.eof then
users = dbrs.GetRows()
end if
db.close
set db = nothing
' DISPLAY DATA
for user = lbound(users,2) to ubound(users,2)
response.write "UserId: " & users(0,user)
response.write "Username: " & users(1,user)
response.write vbNewLine
next
Use the GetRows method to copy records from a Recordset into a two-dimensional array. The first subscript identifies the field and the second identifies the record number. The array variable is automatically dimensioned to the correct size when the GetRows method returns the data.
Dim UserId
Const UserId = 0