IIS ASP - Help with Arrays (VBScript)

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > April 2005 > Help with Arrays (VBScript)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Help with Arrays (VBScript)
joe

2005-04-23, 2:50 am

Xref: TK2MSFTNGP08.phx.gbl microsoft.public.inetserver.asp.general:293231

Hello:

I am scratching my head here. I was trying to copy values from a recordset
into an array, but whatever I do,
I keep getting errors. Let me give an example similar to what my code
initially looked like:

'--- sql and recorset creation here ...etc.

Dim MyArray, intTemp
intTemp = 0

Do Until RS.EOF
MyArray(intTemp) = RS("SomeData")
RS.MoveNext
Loop

The above gave me a type mismatch error, without much information.
Apparentely the array didnt like the
variable intTemp. But I thought that maybe its required that I specify the
lenght of the array when decalring it, so
I went:

intTemp = Cint(RS.recordcount - 1)
Dim MyArray(intTemp) '--- hoping that the array would have the same lenght
as the RS

The error I got now is:

Expected integer constant
[sniped reference to specific line in the code]
Dim MyArray(intTemp)

Aren't I making an integer with Cint?

Any help is appreciated.


dlbjr

2005-04-23, 2:50 am

'This will be far more efficient

'Connect
MyArray = rs.GetRows()
'DisConnect
intMax = UBound(MyArray ,2)

'Here is an example of looping thru the array if the recordset return 2 columns
For i = 0 To intMax
item1 = MyArray(0,i)
item2 = MyArray(1,i)
item3 = MyArray(2,i)
Next

'dlbjr
'Pleading sagacious indoctrination!


dlbjr

2005-04-23, 2:50 am

oops! make that 3 columns

--
'dlbjr
'Pleading sagacious indoctrination!


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com