在我询问之前"如何从填充了数据库的列表框中删除项目"
是否可以从填充了数据库的列表框中删除项目?
如果可能,我的代码无效:
Dim str As String
Dim drv As DataRowView = CType(ListBox1.SelectedItem, DataRowView)
str = CStr(drv.Row.Item("PName"))
ListBox1.Items.Remove(ListBox1.SelectedItem(str))
这是我填充我的lsitbox
的方式 'Populate the ListBox with personnelName from personnel '
Try
connection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nikko Jaze Fabellon\Documents\ASRASIM.accdb")
connection.Open()
ds = New DataSet
tables = ds.Tables
dataAdapter = New OleDbDataAdapter("SELECT [FirstName],[LastName] from [Personnel] where [Status] = 'Activated' ", connection)
dataAdapter.Fill(ds, "Personnel")
Dim view1 As New DataView(tables(0))
With personnelList
.DataSource = ds.Tables("Personnel")
.DisplayMember = "FirstName"
.ValueMember = "LastName"
.SelectedIndex = 0
End With
connection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
或者如果不可能,我需要建议以另一种方式思考。