i have two combo boxes named comboBox1 and comboBox2. the cmbbox1 is filled with item names i have added manually before. upon selecting the item in the cmbbox1, i want to fill the cmbbox2 with the corresponding supplier which drawn from the database. sometime there are more than one supplier for an item. in that case i want to fill the combobox 2 with all the suppliers to allow the user to select the supplier..
Dim cn As New SqlConnection
Dim cmd As New SqlCommand
Dim adapter As New SqlDataAdapter
Dim dr As SqlDataReader
Dim dt As New DataTable
cn.ConnectionString = ("Data Source=NIMO-HP\SQLEXPRESS;Initial Catalog=FYP_db;Integrated Security=True")
cmd.Connection = cn
cn.Open()
cmd.CommandText = "SELECT comName FROM TblSuppliers WHERE comSitem ='" & ComboBox1.Text & "'"
dr = cmd.ExecuteReader
dt.Load(dr)
ComboBox2.Text = dt