954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with MS Access

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!

sanjon
Newbie Poster
5 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

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
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

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!

sanjon
Newbie Poster
5 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

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!

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: