我有一個名爲PriceTesting
(使用Microsoft Access 2007)數據庫:包含與列名爲<code>tbl_dress</code>表將數據綁定微軟接取到文本框
Dress_ID, Dress_Name, Dress_Price
在窗體中,我創建了一個組合框和文本框。
到目前爲止,我已經成功地使用此代碼Dress_Name
數據與綁定組合框: -
Private Sub FillCombo()
Try
Dim fillcon As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\annonymous\Documents\Visual Studio 2012\Projects\DressTest\DressTest\db\PriceTesting.accdb")
Dim query As String = ("SELECT Dress_Name FROM tbl_dress")
Dim da As New OleDb.OleDbDataAdapter(query, fillcon)
Dim ds As New DataSet
da.Fill(ds)
ComboBox1.ValueMember = "Dress_Name"
ComboBox1.DataSource = ds.Tables(0)
ComboBox1.SelectedIndex = 0
Catch ex As Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try
End Sub
和它的作品......每次加載窗體,組合框包含Dress_Name
列中的數據。
現在我想的texbox.text = Dress_Price WHERE Dress_Name = combox.selecteditem
任何想法如何做到這一點? 我心目中僅僅是這樣的: -
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
query = " SELECT Dress_Price FROM tbl_dress WHERE Dress_Name = ' " & Combobox1.Text & " ' "
Textbox1.text = query
End Sub
另外,這個問題與Visual Studio無關。 –