Donutboy
This code shows the use of a dynamic array for the storage of data. Recordsets are memory hogs, and shouldn't be passed across the server, so why even use one? What I was doing with this code was displaying a list of users on my website. After getting the data, I would have it build a table for the information and create hyperlinks for the appropriate fields. I've seen others do this, but they use recordsets to build them, which defeats its purpose. All the code is done with one trip to the server, so you won't see all those carrot tags being opened and closed throughout my work : )
KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
<%@ Language=VBScript %>
<%
DIM vArray
DIM i
SUB FillArray
DIM adoCN
DIM strSQL
strSQL = "SELECT UserName, FirstName, LastName, Email, Website FROM Users Order by UserName"
SET adoCN= server.CreateObject("ADODB.Connection")
WITH adoCN
.ConnectionString= "FileDSN=DonutboyWeb"
.CursorLocation=3
.Open
vArray = adoCN.Execute(strSQL).GetRows
END WITH
SET adoCN=NOTHING
END SUB
response.write "<HTML>"
response.write "<HEAD>"
response.write "<META NAME='GENERATOR' Content='Microsoft Visual Studio 6.0'>"
response.write "</HEAD>"
response.write "<BODY>"
response.write "<H1>User Directory</H1>"
FillArray()
Response.Write "<TABLE border=1 cellPadding=1 cellSpacing=1 ><TH colspan=2>User Name</TH><TH colspan=2>First Name</TH>"
Response.Write "<TH colspan=2>Last Name</TH><TH colspan=2>Email</TH><TH colspan=2>Website</TH>"
for i = 0 to UBOUND(vArray,2)
Response.Write "<TR>"
Response.Write "<TD colspan=2>" & vArray(0,i) & "</TD>"
Response.Write "<TD colspan=2>" & vArray(1,i) & "</TD>"
Response.Write "<TD colspan=2>" & vArray(2,i) & "</TD>"
IF instr(1,vArray(3,i),"@") THEN
Response.Write "<TD colspan=2><A href='mailto:" & vArray(3,i) & "'>" & vArray(3,i) & "</A></TD>"
ELSE
Response.Write "<TD colspan=2>" & vArray(3,i) & "</TD>"
END IF
IF INSTR(1,vArray(4,i),"http://") THEN
Response.Write "<TD colspan=2><A href='" & vArray(4,i) & "'>" & vArray(4,i) & "</A></TD>"
ELSE
Response.Write "<TD colspan=2>" & vArray(4,i) & "</TD>"
END IF
Response.Write "</TR>"
next
Response.Write "</TABLE></BODY></HTML>"
%>