Imports System.Data.OleDbPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim con As OleDbConnection = New OleDbConnection( _ "Provider=Microsoft.jet.oledb.4.0;data source=E:\我的项目\图书管理信息系统\图书管理信息系统\book.mdb") Dim cmd As OleDbCommand = New _ OleDbCommand("SELECT book_name,book_id FROM book_info", con) con.Open() Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd) Dim myDataSet As DataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") '第一种 ComboBox1.DataSource = myDataSet.Tables("MyTable").DefaultView ComboBox1.ValueMember = "book_name" ComboBox1.DisplayMember = "book_info" ' 第二种 'For Each dRow As DataRow In myDataSet.Tables("MyTable").Rows ' ComboBox1.Items.Add(dRow.Item("Username")) 'Next con.Close() con = Nothing
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = ComboBox1.SelectedValue
End SubEnd Class
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = ComboBox1.SelectedValue
End SubEnd Class