navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

option explicit and getrows

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> option explicit and getrows
Page: [1]
 
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: 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.

(in reply to yogaboy)
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.

(in reply to BeTheBall)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> option explicit and getrows
Page: [1]
Jump to: 1





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