|
| |
|
|
yogaboy
Posts: 377 Joined: 5/22/2004 Status: offline
|
option explicit and getrows - 3/26/2005 9:15:28
Quick quiz... If I'm using getrows and option explicit, do I need to declare the array I use with the getrows and if so, how am I going to initialize it without knowing how may records will be returned? The first prize is a small country on Venus. It's nice and warm there.
|
|
|
|
BeTheBall
Posts: 6493 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.
|
|
|
|
yogaboy
Posts: 377 Joined: 5/22/2004 Status: offline
|
RE: option explicit and getrows - 3/26/2005 12:06:14
Thanks! By initializing the array I meant that normally with an array if you declare it without specifying the upper bound then you need to initialize it by using ReDim, Dim myArray() ReDim myArray(5) but I see that's not needed in the code you gave. Thanks again Duane, really helpful stuff.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|