473,511 Members | 15,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Matching array index to values retrieved from database

Hello friends,

I have this dynamic array(shown below) that I need to match to values
(1 - 10) that I am returning from the database via DSN connection
object. The values I need to match are on the same page (in their own
table) but I am not sure how to match up the array indexes to these
values. I want to be able to display the array result as part of or
nested in another table.

Thanks in advance,
John Wilson
Programmer/Analyst

<td valign="top">
<h3>Dynamic Array</h3>
<%
' Now on to our dynamic array. Before I can use a dynamic array
' I need to tell it how many elements I want to be able to put
' into it. The ReDim command allows us to redimension an array
' to whatever size we need. I'm setting it to 2 elements so I
' use an upper bound of 1.

ReDim arrResponses(9)

arrResponses(0) = "Q1"
arrResponses(1) = "Q2"
arrResponses(2) = "Q3"
arrResponses(3) = "Q4"
arrResponses(4) = "Q5"
arrResponses(5) = "Q6"
arrResponses(6) = "Q7"
arrResponses(7) = "Q8"
arrResponses(8) = "Q9"
arrResponses(9) = "Q10"

' Show what our array currently contains:
ShowArrayInTable(arrResponses)

ReDim Preserve arrResponses(15)

' Adding another value:
arrResponses(10) = "Q11"
arrResponses(11) = "Q12"
arrResponses(12) = "Q13"
arrResponses(13) = "Q14"
arrResponses(14) = "Q15"
arrResponses(15) = "Q16"

' Once again show what our array currently contains:
ShowArrayInTable(arrResponses)
%>
</td>
Jul 19 '05 #1
2 4831
From you code, I don't fully understand what you're trying to do. I don't
see any recordsets or anything. But, are you saying you want to be able to
pull out values from an array on demand by calling them by their ID from a
recordset? If so, you could use a dictionary object if you don't want to
keep
a recordset open throughout your page. You could do:

Dim objDict
Set objDict = Server.CreateObject("Scripting.Dictionary")
Set rs = YourConnection.Execute("select UniqueID, OtherColumn from yourTable
where Whatever='whatever'")
Do While Not rs.EOF
objDict.Add rs.Fields(0).Value, rs.Fields(1).Value
rs.MoveNext
Loop
rs.Close
Set rs = nothing
YourConnection.CLose
Set YourConnection = Nothing
Then, if you want to go grab item with ID number 5 at any time, you'd do:

response.write objDict.Item(5)
- Your key values (the first argument in the .Add method) have to be
unique, but if you're using your PK, that'll be fine.
- Don't forget to destroy your dictionary object when you're all finished
with it.\

If I didn't understand what you meant and this makes no sense, sorry.

Ray at home

"John Wilson" <jo***********@hotmail.com> wrote in message
news:11**************************@posting.google.c om...
Hello friends,

I have this dynamic array(shown below) that I need to match to values
(1 - 10) that I am returning from the database via DSN connection
object. The values I need to match are on the same page (in their own
table) but I am not sure how to match up the array indexes to these
values. I want to be able to display the array result as part of or
nested in another table.

Thanks in advance,
John Wilson
Programmer/Analyst

<td valign="top">
<h3>Dynamic Array</h3>
<%
' Now on to our dynamic array. Before I can use a dynamic array
' I need to tell it how many elements I want to be able to put
' into it. The ReDim command allows us to redimension an array
' to whatever size we need. I'm setting it to 2 elements so I
' use an upper bound of 1.

ReDim arrResponses(9)

arrResponses(0) = "Q1"
arrResponses(1) = "Q2"
arrResponses(2) = "Q3"
arrResponses(3) = "Q4"
arrResponses(4) = "Q5"
arrResponses(5) = "Q6"
arrResponses(6) = "Q7"
arrResponses(7) = "Q8"
arrResponses(8) = "Q9"
arrResponses(9) = "Q10"

' Show what our array currently contains:
ShowArrayInTable(arrResponses)

ReDim Preserve arrResponses(15)

' Adding another value:
arrResponses(10) = "Q11"
arrResponses(11) = "Q12"
arrResponses(12) = "Q13"
arrResponses(13) = "Q14"
arrResponses(14) = "Q15"
arrResponses(15) = "Q16"

' Once again show what our array currently contains:
ShowArrayInTable(arrResponses)
%>
</td>

Jul 19 '05 #2
Hello Ray,

Thanks for the quick response. Your example might be exactly what I need
and I will try it. What I need to do is populate the array from one
database table, the values of which I alrady have on my asp page in an
html table, and match the indexes/keys of that array to an id_field
value in another html table which is being populated from the values of
another (db)table. In other words, I have two calls/queries(stored
procs) going to the database, and once I have the data on the page,
which I do, then I want to use memory objects (arrays) to make up the
relationship between the array and the other resultset because, I only
need to perform an insert/update on one of the tables (the one
populating the array), but the data is in one row (responses 1-10), but
the other table has rows(questions) that have to be returned for each
question in that one row. Hope this wasn't too confusing. If you're
interested I would be happy to send you whatever you need to take a
better look.

TIA,
John Wilson
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

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

Similar topics

0
1152
by: t0642k8 | last post by:
Help , the script is executing nice , until it come to the section below. The data out of the Database is a full string with whitespaces in between each word. For example it the variable is "the...
17
14023
by: Andrew McLean | last post by:
I have a problem that is suspect isn't unusual and I'm looking to see if there is any code available to help. I've Googled without success. Basically, I have two databases containing lists of...
3
10420
by: Mark A Framness | last post by:
Greetings, I am working on a project and we need to write a conversion script to initialize a new field on a table. The number of records on this table is on the order of millions so routine...
0
2723
by: Tom Warren | last post by:
I found a c program called similcmp on the net and converted it to vba if anybody wants it. I'll post the technical research on it if there is any call for it. It looks like it could be a useful...
67
4391
by: Ike Naar | last post by:
Hi, Asking your advice on the following subject: Suppose I want to find out whether a given pointer (say, p) of type *T points to an element of a given array (say, a) of type T. A way to...
4
5014
by: Haydnw | last post by:
Hi, I'd like to put a load of database results (several rows for 5 fields) into a two-dimensional array. Now, this may be a really stupid question, but can someone give me a pointer for how to...
6
2712
by: sgottenyc | last post by:
Hello, If you could assist me with the following situation, I would be very grateful. I have a table of data retrieved from database displayed on screen. To each row of data, I have added...
4
6485
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
4
1560
by: pavanponnapalli | last post by:
hi, Here is my Code as under: #! /usr/bin/perl -w use DBI; my %hash; my @arr; my @arr1; my @arr2;
0
7356
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
7427
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...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
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
5671
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,...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.