473,406 Members | 2,713 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,406 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 1899

"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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.