Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Re: Returning A Collection From Database


Message #1 by "Frankie Loh Teck Seng" <lohts@p...> on Sat, 2 Sep 2000 07:59:43 +0100
Funcion f_ReturningCollection () as Variant

Dim l_Result as New Collection
Dim l_Items as New Collection
Dim l_Record as New Collection

' all the connection and the recordset is already prepared

Do While Not oRS.EOF
    l_Record.Add oRS.Fields("Field1"), key:= "Field1"
    l_Record.Add oRS.Fields("Field2"), key:= "Field2"
    l_Items.Add l_Record
    Set l_Record = Nothing
    oRS.MoveNext
Loop

l_Result.Add l_items, key:="items"

Set f_ReturningCollection = l_Result

End Function


In the other side, just receive the collection and access the information,

Hope it helps,

Geoffrey Chu

  Return to Index