我正在尝试制作一个列表框来显示 Access 数据库中特定表的所有字段。我有几张桌子,想法是让每张桌子都由不同的按钮加载(并清除框中的项目)。一个技巧是桌子的大小并不完全相同。如何让每个表的所有字段都显示出来。我现在只显示一个字段:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;data source='C:\dummy_data.accdb';"
Dim conn As New OleDbConnection(connString)
Dim sql As String = "SELECT * FROM Customers"
Dim cmd As New OleDbCommand(sql, conn)
conn.Open()
Dim reader As OleDbDataReader = cmd.ExecuteReader()
ClientList.Items.Clear()
While reader.Read()
ClientList.Items.Add(reader(0).ToString())
End While
reader.Close()
conn.Close()
End Sub