level 1
caroki1014
楼主
在做一个商品登录的程序,有三个可以选商品的下拉框combobox1,2,3和对应的显示价格的文本框textbox1,2,3,数据库里有个product的表,里面有product_code*商品码,primary key),product_name(商品名),price(价格),想把product_name的内容放进下拉框,price的内容放进文本框,在下拉框选商品名的时候文本框里显示对应的价格
数据放进下拉框显示下拉框的内容成功了,但怎么都没办法在文本框里显示对应的内容,求大神们帮帮忙T T
下面是下拉框部分的代码
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Conn.ConnectionString = "Server=(local);Database=receiptdb;Integrated Security=True"
Conn.Open()
Dim Cmd As New SqlCommand(strSql, Conn)
da = New SqlDataAdapter(Cmd)
da.Fill(ds, "product")
Dim i As Integer
For i = 0 To ds.Tables("product").Rows.Count - 1
ComboBox1.Items.Add(ds.Tables("product").Rows(i).Item("product_name"))
ComboBox2.Items.Add(ds.Tables("product").Rows(i).Item("product_name"))
ComboBox3.Items.Add(ds.Tables("product").Rows(i).Item("product_name"))
Next
ComboBox1.Items.Insert(0, "")
ComboBox2.Items.Insert(0, "")
ComboBox3.Items.Insert(0, "")
2018年08月31日 02点08分
1
数据放进下拉框显示下拉框的内容成功了,但怎么都没办法在文本框里显示对应的内容,求大神们帮帮忙T T
下面是下拉框部分的代码
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Conn.ConnectionString = "Server=(local);Database=receiptdb;Integrated Security=True"
Conn.Open()
Dim Cmd As New SqlCommand(strSql, Conn)
da = New SqlDataAdapter(Cmd)
da.Fill(ds, "product")
Dim i As Integer
For i = 0 To ds.Tables("product").Rows.Count - 1
ComboBox1.Items.Add(ds.Tables("product").Rows(i).Item("product_name"))
ComboBox2.Items.Add(ds.Tables("product").Rows(i).Item("product_name"))
ComboBox3.Items.Add(ds.Tables("product").Rows(i).Item("product_name"))
Next
ComboBox1.Items.Insert(0, "")
ComboBox2.Items.Insert(0, "")
ComboBox3.Items.Insert(0, "")