Dim objConn As New OleDbConnection
Dim objCmd As OleDbCommand
Dim dtAdapter As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
strConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Test\Documents\Visual Studio 2013\Projects\LAB APP\LAB APP\bin\Debug\database.accdb;"
'objConn = New OleDbConnection(strConnString)
objConn.ConnectionString = strConnString
objConn.Open()
strSQL = "SELECT * FROM sample"
objCmd = New OleDbCommand
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dt = ds.Tables(0)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
end sub
c1.DataSource = dt
c1.DisplayMember = "ID"
c1.ValueMember = "productname"
Private Sub c1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles c1.SelectedIndexChanged
l2.Text = c1.SelectedValue.ToString()
End Sub
End Class