Mohammad Ishaq

Mohammad Ishaq

  • NA
  • 55
  • 19k

Help me to connect the access DB

May 30 2014 2:59 PM

Hello to Everyone

I have a combo box on the VB 2008 form.And i am using Access 2007 as database .Now i want to populate the combo box using Access table data base. For this purpose i have write the code but it gives me error.Please let me clear by any experience person to check and correct the code.
My Access file name is "a". and is available on drive E.
For better understand i have also upload a screenshot.

Public Class Form1

  Dim cn As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;Data     Source=E:/a.mdb")

    Dim da As New OleDb.OleDbDataAdapter()
    Dim dt As New DataTable()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        cn.Open()

        ComboBox1.Items.Clear()
        Dim r As DataRow
        For Each r In dt.Rows
        ComboBox1.Items.Add(r(1).ToString)
        Next

        cn.Close()



    End Sub
End Class


Thanks For Your Co-Operation



Attachment: my screenshot.zip

Answers (1)