Reading an MS Access DB into an Array

  • Thread starter Thread starter jtnpham
  • Start date Start date
J

jtnpham

Is there any possible way to first pull informatio from a table, and
then "read" all fields into an array?

For example: My table has fields Center, Name, Capacity. After
displaying the table in a data grid view I want to store each of these
values into a multidimensional array. Namely center(i), name(i), and
capacity(i). That way if I wanted a specific value to be assigned to
n I could just write the statement, n = center(1).

Any suggestions/help?!?

Thanks! =)
 
Is there any possible way to first pull informatio from a table, and
then "read" all fields into an array?

For example: My table has fields Center, Name, Capacity. After
displaying the table in a data grid view I want to store each of these
values into a multidimensional array. Namely center(i), name(i), and
capacity(i). That way if I wanted a specific value to be assigned to
n I could just write the statement, n = center(1).

Any suggestions/help?!?

Thanks! =)

Why would you go through all of that?

You Dim an array like MyObjects.

You create an (object) MyObject if you like with Accessor Properties for
each field.

You read the Access Table record.

You instantiate MyObject as New.

For each table record read, you transfer field data to a Myobject Accessor
Property like this.

Myobject.Center = recordfield("Center")

You then populate Myobjects with Myobject.

Myobjects.additem(Myobject).

Then you can run up and down the Myobjects array that holds a Myobject with
a (for loop of off an idx) and access the data in a given Myobject.

To get the data out of an Myobject in a for loop off of an idx, it would be
like this.

Center.text = Myobjects.Myobject.Center(i)

Or to set it, it would be Myobjects.Myobject.Center(i) = Center.text

You can also Bind Myobjects to the datagridview, since the array also
incorporates the IBinding interface.

You can also do the same thing with a Strong Type Collection which is just
another array type that has more power than a simple array.
 
Back
Top