BeTheBall
Posts: 6359 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: option explicit and getrows - 3/26/2005 11:56:50
Yes, you will get an error if you don't declare the array. As far as "initializing" the array, I am not positive what you mean by that. Generally, you use a For/Next Loop to gather the data from the array. Here is a simply example that displays one field from a table in a one-column, multi-rowed table: <%option explicit%>
<html>
<head>
<title>Test</title>
<meta name="Microsoft Border" content="tlrb, default">
</head>
<body>
<%
Dim conntemp, myDSN, myRS, mySQL, arrTable, nRows, row, col
Set conntemp=Server.CreateObject("ADODB.Connection")
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("fpdb/Review304.mdb")
conntemp.open myDSN
mySQL = "SELECT IDRS, [Name] FROM Employees"
Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.Open mySQL, conntemp, 0, 1
arrTable=myRS.GetRows()
myRS.Close
Set myRS = nothing
conntemp.Close
Set conntemp = nothing
%>
<TABLE BORDER=1>
<%
nRows = UBound(arrTable, 2 )
For row = 0 To nRows
%>
<TR>
<%
For col = 0 To UBound(arrTable, 1 )
%>
<TD><%=arrTable(col, row)%> </TD>
<% Next %>
</TR>
<% Next %>
</TABLE>
<p> </body>
</html>
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|