Hello,

I have just started using databases, but I am totally stuck. I made a database and table using MS Access. The table has three columns. ID, Code, and Letter. Basically, the Code column stores a number for each letter (eg. 1 = A, 2 = B, 3 = C, etc.)

Table:

|ID|Code|Letter|
| 2| 1| A|
| 3| 2| B|
| 4| 3| C|
etc.

This table is just for reference for my program, and I don't need to change any values. But I need a step by step guide to link this table to VB 2010 and convert the values of the table to an array. For example: convert the table into the array "example" which means that example(1) = A, example(2) = B, example(3) = C and so on. I hope you get what I mean.

Sorry if I missed something totally obvious, but like I said I just started with this today. Thanks a lot!

Firstly, read one after one record from the ms-access database and assign it to List or Dictionary.

Dim Adp as New OleDbDataAdapter("select * from yourtableName","connection_string_here")
Dim Dt as New DataTable
Adp.Fill(Dt)


 Dim coll As New Dictionary(Of String, String)

 For Each row As DataRow In Dt.Rows
      coll.Add(row("Code"), row("Letter"))
 Next

Firstly, read one after one record from the ms-access database and assign it to List or Dictionary.

Dim Adp as New OleDbDataAdapter("select * from yourtableName","connection_string_here")
Dim Dt as New DataTable
Adp.Fill(Dt)


 Dim coll As New Dictionary(Of String, String)

 For Each row As DataRow In Dt.Rows
      coll.Add(row("Code"), row("Letter"))
 Next

OK I will try this. Thanks a lot in advance.

Edit:

It worked perfectly. Thanks a lot!! I will come back here if I need any extra help. Thanks again!

You're welcome! I'm glad you got it working. Please mark this thread as solved if you have found an answer to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.