• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Loading a bi-dimensional array and RS(s)

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
skullj
Asked:
skullj
  • 5
  • 4
1 Solution
 
CJ_SCommented:
Could you show an example of the exact formatting?
0
 
skulljAuthor Commented:
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
 
CJ_SCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
skulljAuthor Commented:
Dear CJ_S,
I need then to call the bi-dimensional array that will be returned form the VB function from ASP...
thanx
0
 
CJ_SCommented:
>> be returned form the VB function from ASP

??
0
 
skulljAuthor Commented:
TO ASP ..SORRY
0
 
CJ_SCommented:
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
 
skulljAuthor Commented:
TO ASP ..SORRY
0
 
skulljAuthor Commented:
sorry..just a last question : what is Array(rs("id"), tmpStr)??
Thank
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now