Need help using VB.NET to retrieve ACCESS data.

I am a complete newbie to VB.NET programming. All I am trying to do is retrieve all the data from an ACCESS database and then loop through it to store it in an array.

Maybe I dont need to store it in an array. The concepts of datasets are strange to me. How do I access specific records in the datasets. I have a book on the subject, but it is only using bound controls (the datagrid). I don't want to use the bound controls at all.

I have set up my database connection(OleDbConnection1) and data adapter(OleDbAdapter1). I also have a dataset ("Blinds_Dataset").  The table is very simple. an ID (key) column, and two data columns.

This is so frustrating compared to the old way of SQL into recordsets or arrays.  ((its been 10 years since I wrote even one line of code =). )

Thanks

M
dunnieboyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iboutchkineCommented:
Imports System.Data.OleDb

Public Class Form1
   Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
#End Region
   Dim fsConn As String = _
  "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  "Data Source=C:\TestDB\TestDB.mdb;"

   Dim ds As DataSet
   Dim da As OleDbDataAdapter
   Dim fsSQL As String = "SELECT * FROM Test"
   Dim fsSource As String = "Test"

   Private Sub CreateDS()
       ds = New DataSet()
       'Connect to database and specify sSQL
       da = New OleDbDataAdapter(fsSQL, fsConn)

       Try
           'using DataAdapter enter records from table to DataSet
           da.Fill(ds, fsSource) 'fsSource is a table
       Catch objExc As System.Exception
           'do something
           Exit Sub
       End Try
   End Sub

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.CreateDS()
       dg.DataSource = ds.Tables("Test")
        dg.DataMember = "Test"
   End Sub

End Class



now you have all the records in the datatable  Test


you can read these records like that

Dim dr As DataRow

For Each dr In Ds.Tables("Test").Rows
   Listbox1.Items.Add(dr.Item("Field1").ToString)
Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.