?
Solved

Loading a bi-dimensional array and RS(s)

Posted on 2001-08-06
9
Medium Priority
?
314 Views
Last Modified: 2008-03-06
Dear all,

I have an array containing a list of product IDs related to a certain user.

Dim counter As Integer
counter = 0
For counter = LBound(arryID) To UBound(arryID)
MsgBox arryID(counter)
Next counter

arryID is the array containing the IDs.

What I would need is the following:
within the loop of the array -- x each element of the array -- I need to launch n SELECT(s)of this kind: select from mytable where ProductID = ID.
Then I need to load a bi-dimensional array where the 1 dimension is (one of) the ID on the basis of which I am doing the SELECT , and the 2 dimension is a string of all the exixting values in the DB for that ID chained by a comma.

Thanx.
 

0
Comment
Question by:skullj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6355047
Could you show an example of the exact formatting?
0
 

Author Comment

by:skullj
ID: 6355079
Thanx CJ_S

'1 VERSION OF THE STRING

 stringa = stringa + Rs2.Fields("ID").VALUE + ","

 '2 VERSION OF THE STRING: I need to strip off the last ","
 'I need this formatted version to be loaded into the array

 stringa = mid(stringa ,1,len(stringa )-1)  
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6355113
Doesn't make much sense to me so far.

if I understand you correctly you are trying to achieve the following:
- loop through the array
- inside the loop you create an sql statement which will select some data out of the database
- then you want to retrieve the id, and place it in the first entry, the second entry will be used to place all other fields, comma sperated. is that correct? if so, the following might help you a bit

Declare the following type:
Public Type MyRS
   id as integer
   addData as string
End Type


then in your normal function / loop

Dim counter As Integer
Dim myArray() as MyRS
For counter = LBound(arryID) To UBound(arryID)
   .. create sql statement...that's up to you..
   rs.open SQLSTATEMENT
   ReDim preserve myArray(counter)
   myArray(counter).id = rs("id")
   for each y in rs.fields
      tmpStr = tmpStr & rs(y).Value & ","
   next
   tmpStr = Left(tmpStr, len(tmpStr-1))
   myArray(counter).addData = tmpStr
Next counter

If this is not what you wer elooking for, just clarify some more on your goal.

regards,
CJ
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:skullj
ID: 6355117
Dear CJ_S,
I need then to call the bi-dimensional array that will be returned form the VB function from ASP...
thanx
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6355124
>> be returned form the VB function from ASP

??
0
 

Author Comment

by:skullj
ID: 6355132
TO ASP ..SORRY
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 800 total points
ID: 6355158
UHM...

public function myfunction() as variant()
Dim counter As Integer
Dim myArray as variant

For counter = LBound(arryID) To UBound(arryID)
  .. create sql statement...that's up to you..
  rs.open SQLSTATEMENT
  ReDim preserve myArray(counter)
  for each y in rs.fields
     tmpStr = tmpStr & rs(y).Value & ","
  next
  tmpStr = Left(tmpStr, len(tmpStr-1))
  myArray(counter) = Array(rs("id"), tmpStr)
Next counter

myfunction = myArray
end function

I suppose that would return the array to the asp page. Now you should be able to use the following in your asp page:
Set x = Server.CreateObject("Myproject.classname")
y = x.myfunction
for i=lbound(y) to ubound(y)
   response.write("id: " & i(0) & "<br>data: " & i(1))
next

rgards,
CJ
0
 

Author Comment

by:skullj
ID: 6355225
TO ASP ..SORRY
0
 

Author Comment

by:skullj
ID: 6355769
sorry..just a last question : what is Array(rs("id"), tmpStr)??
Thank
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question