Reading an MS Access DB into an Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jtnpham@gmail.com

    #1

    Reading an MS Access DB into an Array

    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 multidimensiona l 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! =)

  • Mr. Arnold

    #2
    Re: Reading an MS Access DB into an Array


    <jtnpham@gmail. comwrote in message
    news:1179758549 .270908.212970@ x18g2000prd.goo glegroups.com.. .
    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 multidimensiona l 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("Ce nter")

    You then populate Myobjects with Myobject.

    Myobjects.addit em(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.Myobj ect.Center(i)

    Or to set it, it would be Myobjects.Myobj ect.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.




    Comment

    Working...