'Populate the ListBox with personnelName from personnel ' Try myConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nikko Jaze Fabellon\Documents\ASRASIM.accdb") myConnection.Open() ds = New DataSet tables = ds.Tables da = New OleDbDataAdapter("SELECT [FirstName],[LastName] from [Personnel] where [Status] = 'Activated' ", myConnection) da.Fill(ds, "Personnel") Dim view1 As New DataView(tables(0)) With personnelList .DataSource = ds.Tables("Personnel") .DisplayMember = "FirstName" .ValueMember = "LastName" .SelectedIndex = 0 End With myConnection.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim str As String str = personnelList.SelectedItem.ToString() ListBox1.Items.Add(str) End Sub
Dim str As String Dim drv As DataRowView = CType(ListBox1.SelectedItem, DataRowView) str = CStr(drv.Row.Item("FirstName")) & " " & CStr(drv.Row.Item("LastName")) ListBox2.Items.Add(str)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)