Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb collections and database access 1

Status
Not open for further replies.

grimmersnee

Programmer
Nov 7, 2002
2
NZ
I am new to the concept of collections and I am trying to read data from an access db into a collection, does anyone know of any simple examples on the net that could illustrate this? It would be very much appreciated
 
I don't think it can be done directly - if it can, I'd like to know how!
What I usually do is something like this:

Declare a class to hold a row of data
Create a Collection to hold the objects created from my class
Get the recordset from my database (table or query)
Load it into an array with rs.GetRows (note that the array indices are column, row)
Loop through the array, creating new classes, loading them from the column values and adding them to my collection

If I need to be able to look up objects, I add a "Key" property to the class that returns some unique combination of its values as a string. So my collection adding code would be something like

myCol.Add newObject, newObject.Key
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top