473,230 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

incomplete data in muliple dimension array

Hi everybody

The output of my multiple dimension array is quite confusing.

Im declaring an array, store some values in it and then I save the array
in a session variable. On an other page I store the data of the
session in a new multiple dimension array.

All data are saved correctly in the array of the 1st page. But in the
new array of the 2nd page there is only one entry. Does anybody knows
why??? Here the code example...

*****Code of the 1st page*****

i=0
do while Not rs.EOF

Redim array((i)+ 1,9)
array (i,1) = rs.fields("Title")
array(i,2)= rs.fields("Description")
array(i,3)= rs.fields("DocLanguage")
array(i,4)= rs.fields("DateCreated")
array(i,5)= rs.fields("Category")
array(i,6)= rs.fields("DateTerminated")
array(i,7)= rs.fields("DateVisible")
array(i,8)= rs.fields("Site")
array(i,9)= rs.fields("DocType")
response.write(array (i,1)) 'output is correct
rs.MoveNext
i = i+1
loop
*****Code of the 2nd page*****

Arrcontent = session("content")
dim test
test = IsArray(Arrcontent)
response.write(test)
for i = 1 to UBound(Arrcontent)
if not Arrcontent(i,1) = "" then
response.write (Arrcontent(i,1)) 'output incorrect only one entry

else
response.write("error") 'quite a lot of errors
end if
Thanks for your help...

Greetings Michael

Jul 22 '05 #1
4 1890

"Michael Kirchner" <mi****@gmx.de> wrote in message
news:B5***************@news2.nokia.com...
Hi everybody

The output of my multiple dimension array is quite confusing.

Im declaring an array, store some values in it and then I save the array
in a session variable. On an other page I store the data of the
session in a new multiple dimension array.

All data are saved correctly in the array of the 1st page. But in the
new array of the 2nd page there is only one entry. Does anybody knows
why??? Here the code example...

*****Code of the 1st page*****

i=0
do while Not rs.EOF

Redim array((i)+ 1,9)
array (i,1) = rs.fields("Title")
array(i,2)= rs.fields("Description")
array(i,3)= rs.fields("DocLanguage")
array(i,4)= rs.fields("DateCreated")
array(i,5)= rs.fields("Category")
array(i,6)= rs.fields("DateTerminated")
array(i,7)= rs.fields("DateVisible")
array(i,8)= rs.fields("Site")
array(i,9)= rs.fields("DocType")
response.write(array (i,1)) 'output is correct
rs.MoveNext
i = i+1
loop
*****Code of the 2nd page*****

Arrcontent = session("content")
dim test
test = IsArray(Arrcontent)
response.write(test)
for i = 1 to UBound(Arrcontent)
if not Arrcontent(i,1) = "" then
response.write (Arrcontent(i,1)) 'output incorrect only one entry

else
response.write("error") 'quite a lot of errors
end if
Thanks for your help...

Greetings Michael


Hi ,

When are the values stored into the session variable in the first page. I
don't see it in the code any where.

One more thing can you tell me whether in the second page you are getting
the first record or only last record something like that.

Regards
Vinod
Jul 22 '05 #2
Vinod wrote:
"Michael Kirchner" <mi****@gmx.de> wrote in message
news:B5***************@news2.nokia.com...
Hi everybody

The output of my multiple dimension array is quite confusing.

Im declaring an array, store some values in it and then I save the array
in a session variable. On an other page I store the data of the
session in a new multiple dimension array.

All data are saved correctly in the array of the 1st page. But in the
new array of the 2nd page there is only one entry. Does anybody knows
why??? Here the code example...

*****Code of the 1st page*****

i=0
do while Not rs.EOF

Redim array((i)+ 1,9)
array (i,1) = rs.fields("Title")
array(i,2)= rs.fields("Description")
array(i,3)= rs.fields("DocLanguage")
array(i,4)= rs.fields("DateCreated")
array(i,5)= rs.fields("Category")
array(i,6)= rs.fields("DateTerminated")
array(i,7)= rs.fields("DateVisible")
array(i,8)= rs.fields("Site")
array(i,9)= rs.fields("DocType")
response.write(array (i,1)) 'output is correct
rs.MoveNext
i = i+1
loop
*****Code of the 2nd page*****

Arrcontent = session("content")
dim test
test = IsArray(Arrcontent)
response.write(test)
for i = 1 to UBound(Arrcontent)
if not Arrcontent(i,1) = "" then
response.write (Arrcontent(i,1)) 'output incorrect only one entry

else
response.write("error") 'quite a lot of errors
end if
Thanks for your help...

Greetings Michael

Hi ,

When are the values stored into the session variable in the first page. I
don't see it in the code any where.

One more thing can you tell me whether in the second page you are getting
the first record or only last record something like that.

Regards
Vinod

Yes in the first Page. Sorry I did not add it..

session ("content") = array 'on the first page
Jul 22 '05 #3
One more thing can you tell me whether in the second page you are getting
the first record or only last record something like that.


It is the last record.

BR Michael
Jul 22 '05 #4
Michael Kirchner wrote:
Hi everybody

The output of my multiple dimension array is quite confusing.

Im declaring an array, store some values in it and then I save the
array in a session variable. On an other page I store the data of the
session in a new multiple dimension array.

All data are saved correctly in the array of the 1st page. But in the
new array of the 2nd page there is only one entry. Does anybody knows
why??? Here the code example...

*****Code of the 1st page*****

i=0
do while Not rs.EOF

Redim array((i)+ 1,9)


This statement is not legal syntax. Are you using On Error Resume Next to
suppress the error message?
Anyways, with a multidimensional array, the only dimension that can be
resized is the last dimension. If you wish to use this time-consuming and
processor-intensive technique to build your array, then you need to swap the
meanings of the dimensions: use the first dimension to denote the column,
and the second dimension to denote the row. Like this ("array" is the name
of a builtin vbscript function, and therefore should be avoided when naming
your variables):

dim arData(), i, rownum
'don't forget, array indexes are zero-based. You shouldn't
'create an array that is larger than what you need
do while Not rs.EOF
rownum=rs.AbsolutePosition - 1
redim Preserve arData(8,rownum)
' another improvement - use a loop to write the data into the array:
for i = 0 to 8
arData(i, rownum) = rs(i).value
next
rs.movenext
loop

Having said that, I must point out that you are doing this the hard way, not
only in terms of writing the code, but also in terms of resource-usage and
performance (recordset loops are SLOW). Your array can be built with a
single line of code:

dim arData
If not rs.EOF Then arData=rs.GetRows

When accessing the data in the array, just be aware that the indexes are
zero-based. To read the data in the 4th field in the 5th row, use:
arData(3,4)

You can aid your memory by using constants:

const cDescription = 0 ,cTitle = 1, ...

So to read the title in the 6th row:
arData(cTitle, 5)
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: James | last post by:
Hi, I am new to C++. I want to directly create a dynamic two-dimension double array, i.e. double pp. I found the "new" is only for one-dimension array, i.e. double *p = new p. How to "new" a...
2
by: YFS DBA | last post by:
Hello again; I've got a small invoicing database I'm trying to create. One of the tables is set up as follows: Client# Date Claim# Amount 1001 10/10/03 ...
5
by: Paul F. Dietz | last post by:
Is the following legal C? struct foo; struct foo (*p); /* Pointer to array of 10 foo structures */ struct foo { int bar; int baz; }; main() { printf("%d\n", sizeof(*p)); } Paul Dietz...
6
by: Eric Smith | last post by:
Is a structure containing an incomplete array as its last element (per paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an incomplete type? That appears to be indicated by paragraph...
7
by: Michael Birkmose | last post by:
Hi everyone!, Are pointers to incomplete types allowed in ANSI C? I can see that pointer arithmic on pointers to incomple types is impossible, however there are situations where it can be...
4
by: Bill Sun | last post by:
Hi, All I have a conventional question, How to create a 3 dimension array by C language. I see some declare like this: int *** array; int value; array = create3Darray(m,n,l);
29
by: yourmycaffiene | last post by:
Okay, this if my first post so go easy on me plus I've only been using C for a couple of weeks. I'm working on a program currently that requires me to read data from a .dat file into a 2d array and...
5
by: Jackson | last post by:
I have something that is stumping me. I am trying to initialize a 3 dimensional string array with the code below, but it wont compile. Can anyone explain what Im doing wrong?????????????? Im...
5
by: moizpalitanawala | last post by:
Hello friends, How to add data to JTable from a .txt file. I had seen this code from one of the tutorial from java.com. This code doesnt take any input. But shows what is written in the array....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.