Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array 2

Status
Not open for further replies.

100dtl

Programmer
Aug 18, 2003
313
GB
If a declare an array

Dim arr(10,2)

How can i reset its size?

Ie I now what it to be

rs.RecordCount()
 
Redim arr(10)
will make your array 10 long ;)
You're trying to make the array as long as there are records right ?
Cause I had some trouble getting the numbers of records without looping through it till EOF and then initting the array like Redim records(i - 1)
RecordsCount() method is only supported if you create the record in a special way. I had a post about it a few days back.. I never managed to get it working, or didn't bother, don't remember. Works just as well just going through the records and incrementing a counter :p
 
Well if i initlise with
redim arr(10,2)

Then i use

arr = rs.GetRows()

I now have the recordset in my array

Now the first dimension carrys the forst row the size of the query i used

select one,two,three from numbersrange where id = 123456

Now if i had 4 rows of the same id then how can i specify the next row and so on?

for i=0 to UBound(arr)
Response.Write &quot;<BR> element 1&quot;&arr(i,1)
next

I'm only catering for this arr arr(thisone,notthisone)

I woudl like to loop the size of all records found

 
I never got the GetRows() method to work either. But you do seem to be addressing your arrays wrong if I'm not mistaking. it's arr(i)(j) not arr(i,j).

<quote>Now the first dimension carrys the forst row the size of the query i used

select one,two,three from numbersrange where id = 123456</quote>
can't make sence out of this. Could you explain diff. please :)
What do you mean by 4 rows of the same id ? you put every row into a different array element like as if you'ld do something like arr(0) = otherarray(&quot;a&quot;,&quot;b&quot;)

With
for i=0 to UBound(arr)
Response.Write &quot;<BR> element 1&quot;&arr(i,1)
next
you get only the 1st element so what you need to do is get the length of the array inside the 1st dimension of the array.
for i = 0 to Ubound(arr)
for j = 0 to Ubound(arr(i))
Response.Write &quot;<BR> element &quot; & j & &quot; from array &quot; & i & &quot; : &quot; &arr(i,j)
next
next


that would show you all elements :)
 
I c.. I've just wrote the two for loops I'm trying..

what i mean is rows are added with the same idorder that is related to a master order table so there a relation ship to

orders
customer
products

this worked..

'testing start
sql = &quot; SELECT orders_split.idorder, orders_split.inorout, orders_split.details, orders_split.sku, orders_split.qty, orders_split.idproduct, orders_split.price, orders_split.taxAmount, customers.idcustomer, customers.name, customers.phone, customers.email, customers.shippingaddress, customers.shippingcity, customers.shippingstate, customers.shippingcountry, customers.shippingzip, customers.customerType, customers.address, customers.zip, customers.state, customers.city, customers.country, orders.authorised, orders.total, products.Stock, orders.subtotal, orders.postage &quot;
sql = sql & &quot; FROM ((customers INNER JOIN orders_split ON customers.idcustomer = orders_split.idcustomer) INNER JOIN orders ON orders_split.idorder = orders.idOrder) INNER JOIN products ON orders_split.idproduct = products.idproduct &quot;
sql = sql & &quot; WHERE (((orders_split.idOrder)=&quot;&rsId(&quot;idorder&quot;)&&quot;))&quot;

set rs = connTemp.Execute(sql)
arr = rs.GetRows()
'ReDim Preserve OrderArray(50,rs.RecordCount())

%><table ID=&quot;Table1&quot;><tr><%
for i=0 to UBound(arr)
'Response.Write &quot;<BR> element 0&quot;&arr(i,0)
%><td><%
for j=0 to UBound(arr)
Response.Write &quot;<BR> element 1&quot;&arr(i,j)
next
%></td><td><%
next
%></td></tr></table><%
'testing start



 
Hi 100dtl,
As correctly suggested by GaryC123,the you refer to an array, which gets it data after Getrows() method , in the form of Arr(numcol,numrow) where numcol is the nth column and numrow is the nth row.Hope it is clear till now.
Now here is how you get the data from the database :-

Set rs = conn.Execute(sql)
alldata = rs.Getrows() 'alldata is the name of the array
numcols=ubound(alldata,1)
numrows=ubound(alldata,2)
' now you can close the connection to the database,if you want
Thats it!!!
If you have any further queries feel free to post it
Regards
Itron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top