Hi, I'm trying to create cascading comboboxes, and my code isn't working. I've looked at other threads and I don't know why it isn't working properly. The first combo box displays System Names and the second combobox should populate the all Locations of that specific system chosen. When I run my application, the first combobox populates without any duplicates just as it shoud but when I select a System Name from it, the location combo box populates just one entry and doesn't allow a drop down of all the other location names. Here's my code:

'---Form_Load
        Dim con As MySqlConnection = New MySqlConnection("Server=fafsv-mysql;user id=root;Password=0263;Database=gsais")
        Dim cmd As MySqlCommand = New MySqlCommand("SELECT DISTINCT SystemName FROM blsys_systems", con)
        con.Open()
        Dim myDA As MySqlDataAdapter = New MySqlDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "blsys_systems")

        SystemComboBox.DataSource = myDataSet.Tables("blsys_systems")
        SystemComboBox.ValueMember = "SystemName"
        SystemComboBox.DisplayMember = "SystemName"
        Me.SystemComboBox.SelectedValue = 0
        con.Close()
        con = Nothing

That part of the code seems to be ok.. here's for the second combo box:

Private Sub SystemComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SystemComboBox.SelectedIndexChanged
        'Populates Location Name Combo box cascading from System Name
        Dim con As MySqlConnection = New MySqlConnection("Server=fafsv-mysql;user id=root;Password=0263;Database=gsais")
        Dim cmd As MySqlCommand = New MySqlCommand("SELECT LocationName, SystemName FROM blsys_systems WHERE SystemName='" & SystemComboBox.Text.ToString & "'", con)
        con.Open()
        Dim myDA As MySqlDataAdapter = New MySqlDataAdapter(cmd)
        Dim ds As DataSet = New DataSet()
        myDA.Fill(ds, "blsys_systems")

        LocationComboBox.DataSource = ds.Tables("blsys_systems")
        LocationComboBox.ValueMember = "LocationName"
        LocationComboBox.DisplayMember = "LocationName"
        LocationComboBox.SelectedValue = 0
        con.Close()
        con = Nothing
    End Sub

Once I get that to start working, the selection of the second combobox should populate textboxes and different datagrids... :(

Firstly, to remove the obvious, if you were to run that query directly against the database how many results should you get?

I should get 13 different results. However, I was able to get this to work. I just had some properties that were set that was conflicting with my code so I turned those properties off. Thanks

I'm working on a system on vb 2008 for a company it need to calculate what the employee work for today .. First my system works like that: The employee enters "Inventory and Total work for today and Pay out for today) then he choose from checkboxes what he desire to calculate from: 1.Profit 2.Available Inventory 3.Pay out 4.Tax (0.925) 5.Total cash and 6.TOTAL ... this is what i code but i'm not sure if the numbers are accurate or not because i have to do it good :

'calculate Total Work : total work * 30% = Profit
        Dim totalwork As Integer = CInt(TextBox12.Text)
        totalwork = CInt(CInt(TextBox12.Text) * (0.925))
        TextBox3.Text = CStr(totalwork)

        'calculate Pay Out : Total Pay Out - Profit = Pay Out
        Dim tpayout As Integer
        Dim paynum As Integer
        Dim pronum As Integer
        tpayout = CInt(Val(TextBox14.Text))
        pronum = CInt(Val(TextBox3.Text))
        paynum = (CInt(Val(TextBox14.Text)) - CInt(Val(TextBox3.Text)))
        TextBox7.Text = CStr(paynum)

        'calculate Available Inventory : Total Inventory - Total Work
        Dim tInv As Integer
        Dim Avinv As Integer
        tInv = CInt(Val(TextBox13.Text))
        Avinv = (tInv - CInt(Val(TextBox12.Text)))
        TextBox6.Text = CStr(Avinv)

        'calculate Total Cash = Profit + Available Inventory
        Dim totcash As Integer
        totcash = (CInt(Val(TextBox3.Text)) + CInt(Val(TextBox6.Text)))
        TextBox9.Text = CStr(totcash)

        'calculate Cash Discount = Total Cash * Discount Rate
        'Dim cashD As Integer
        'Dim disrate As Integer = 30%
        'cashD = totcash * disrate

        'calculate TOTAL = Profit + Available Inventory + Pay Out + Total Cash
        Dim TOTAL As Integer
        TOTAL = (CInt(Val(TextBox3.Text)) + CInt(Val(TextBox6.Text)) + CInt(Val(TextBox7.Text)) + CInt(Val(TextBox9.Text)))
        TextBox10.Text = CStr(TOTAL)

        TextBox17.Text = CStr(0.925)
        Dim i As Double = CDbl(TextBox12.Text)
        i = CDbl(TextBox17.Text) * i
        TextBox8.Text = CStr(i)



    the user enter textbox12:Total work
    textbox13:Inventory
    textbox14:pay out
   and the system calculate: textbox3.text:Profit
   textbox6:Available inventory
   textbox7:Pay out
   textbox8:tax
   textbox9:total cash
   textbox10:TOTAL
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.