473,785 Members | 2,669 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:
ShowArrayInTabl e(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:
ShowArrayInTabl e(arrResponses)
%>
</td>
Jul 19 '05 #1
2 4841
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.CreateOb ject("Scripting .Dictionary")
Set rs = YourConnection. Execute("select UniqueID, OtherColumn from yourTable
where Whatever='whate ver'")
Do While Not rs.EOF
objDict.Add rs.Fields(0).Va lue, rs.Fields(1).Va lue
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.goo gle.com...
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:
ShowArrayInTabl e(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:
ShowArrayInTabl e(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
1161
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 quick brown fox" the data retrieved from the array would be "the" //############################################### // Query DB for distinct Lab name
17
14073
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 postal addresses and need to look for matching addresses in the two databases. More precisely, for each address in database A I want to find a single matching address in database B. I'm 90% of the way there, in the sense that I have a simplistic...
3
10447
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 selection and update takes a long time. I am tasked with writing a pl/sql proc that utilizes array processing to update the column.
0
2748
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 tool for breaking ties when a phonic call returns a bunch of possibilities. Also, I'm looking for someone that has a zip code file with alternate city names (the PO assigns whatever name is convenient to them), email me if you got something. ...
67
4487
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 achieve this would be a linear search through the array: int ptrInArrSafe(T *p,T *a,int max) /* check whether p points to an element of a */
4
5035
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 do it? I can bind data to datagrids and lists and stuff all day long, but can't seem to grasp this one. Any pointers to a useful article / demo (or just any useful pointers!) would be much appreciated. Thanks,
6
2726
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 action buttons, such as "Edit", "Add", and "Comment". Since I do not know how many rows of data will be retrieved - and therefore how many buttons I need - I am using button arrays for each button, like so: echo "<input type=\"submit\"...
4
6501
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 retrieved using list/menu box. When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category. However when i check multiple checkboxes and...
4
1569
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
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.