I'm trying to import all data from an Access DB using Visual Basic 2005. I'm new to Access and so far I can only import one record at a time. Any help would be appreciated!! Here is the code I have so far (obviously to bring one record at a time).

Private Sub BtnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xLoadButton.Click
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String

'Connect to Access 2007
con.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data " & "Source = C:\Users\hp\Documents\Database1.accdb"


sql = "SELECT * FROM table1"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Table1")
'The DataSet (ds) will now be filled with the records selected from table

MsgBox("A Connection to the Database is now open")
'close database connection

MsgBox("The Connection to the Database is now Closed")
xPartNumberCombobox.Text = ds.Tables("table1").Rows(0).Item(1)
xPartNameComboBox.Text = ds.Tables("table1").Rows(0).Item(2)
End Sub

You want all the Rows from the database table returned not just Row 0?

(that was a pretty big hint BTW)

xPartNumberCombobox.Text = ds.Tables("table1").Rows(all).Item(all)?? So do I use all as the index?? What do i set all to after i declare it?

You're getting close..

You have to loop through the values:

dim i as integer
dim DT as datatable
dim DR as Datarow 

'I'm just using DT and DR as I hate having to type out dataset.tables.rows...

DT = ds.Tables("Table1")
'VB uses a zero based index and Count is an actual count therefore we start a zero and end at count-1
for i =0 to DT.Rows.count -1
  DR = DT.Rows(i)

I suggest you look up using loops in VB.NET

This article has been dead for over six months. Start a new discussion instead.