我一直在寻找 3 天,但我找不到我需要的东西。我生疏了,但我在一家为酒店管理 IT 的公司工作。我有一个访问数据库,其中有一列包含酒店名称、街道、邮编、电话等。
酒店名称在我的表单上填充一个组合框。基本上,一旦用户从下拉列表中选择了酒店,我希望其他行中的所有信息(与所选项目的行匹配),例如位置信息和电话,以填充一些标签,但我似乎找不到标签需要什么代码。
CODE:公开课Newticket
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.HotelsdbTableAdapter.Fill(Me.HotelsDataSet1.hotelsdb)
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection _
("provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\Users\David_2\Desktop 2\Skosh\hotelDB.xlsx'; Extended Properties=Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter _
("select * from [Sheet1$]", MyConnection)
MyCommand.TableMappings.Add("Table", "TestTable")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
' cmbHotels.Items.Add = Sheet1$.Range("A1").Text
MyConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Newticket_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
FrmMain.Hide()
End Sub
Private Sub NewTicket_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
FrmMain.Show()
Me.Close()
End Sub
Private Sub lblHotel_Click(sender As System.Object, e As System.EventArgs) Handles lblHotel.Click
End Sub
Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles lblPoc.Click
End Sub
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Label7_Click(sender As System.Object, e As System.EventArgs) Handles Label7.Click
End Sub
Private Sub BindingSource1_CurrentChanged(sender As System.Object, e As System.EventArgs)
End Sub
Private Sub DataGridView1_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs)
End Sub
Private Sub cmbHotels_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbHotels.SelectedIndexChanged
End Sub
Private Function Sheets(p1 As String) As Object
Throw New NotImplementedException
End Function
Private Function Rows() As Object
Throw New NotImplementedException
End Function
Private Function Sheet1() As Object
Throw New NotImplementedException
End Function
Private Sub DataGridView1_CellContentClick_1(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs)
End Sub
Private Sub BindingSource1_CurrentChanged_1(sender As System.Object, e As System.EventArgs) Handles BindingSource1.CurrentChanged
End Sub
Private Sub FillByHotelToolStripButton_Click(sender As System.Object, e As System.EventArgs)
Try
Me.HotelsdbTableAdapter.FillByHotel(Me.HotelsDataSet1.hotelsdb)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
基本上从组合框中选择一家酒店。右侧的一些带有联系信息的标签需要填充酒店信息。我不知道如何处理标签。组合框正在工作。
非常感谢提前