[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Loading a bi-dimensional array and RS(s)

Posted on 2001-08-06
9
Medium Priority
?
319 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
Technology Partners: 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

656 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