Click here to Skip to main content
15,074,987 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have three combobox, combobox1 has preloaded list, based on what the combobox1 value will populate the combobox2. i have no errors on this, but when i try to populate combox3, it gives me "child list or field system cannot be created.

this is the code that were higlighted and gives the the error.

ComboBox3.DataSource = table2
ComboBox3.ValueMember = provincetext
ComboBox3.DisplayMember = provincetext



this is what i am trying to do
combobox1(region) <== preloaded list 
combobox2(province of selected value of region) <== code runs, no error (populated)
combobox3(municipality/city of selected value of province) <== error, (did not populate)


What I have tried:

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

        Dim regiontext As String
        regiontext = ComboBox1.Text
        Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=")
        Dim adapter As New MySqlDataAdapter("select * from eulat.provinces", connection)
        Dim table As New DataTable()
        adapter.Fill(table)

        ComboBox2.DataSource = table
        ComboBox2.ValueMember = regiontext
        ComboBox2.DisplayMember = regiontext

    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        
        Dim provincetext As String
        provincetext = ComboBox2.Text
        Dim connection2 As New MySqlConnection("datasource=localhost;port=3306;username=root;password=")
        Dim adapter2 As New MySqlDataAdapter("select * from eulat.citymun", connection2)
        Dim table2 As New DataTable()
        adapter2.Fill(table2)

        ComboBox3.DataSource = table2
        ComboBox3.ValueMember = provincetext
        ComboBox3.DisplayMember = provincetext
       
    End Sub
Posted
Updated 15-May-21 14:38pm
v3
Comments
CHill60 15-May-21 12:58pm
   
What is provincetext set to?
Member 13755790 15-May-21 20:33pm
   
provincetext should be the value needed to populate the combobox3, it came from the list populated by the combobox1. this is what i am trying to do, combobox1(region),combobox2(province of selected value of region) then combobox3(municipality/city of selected value of province)
CHill60 16-May-21 10:12am
   
Is there actually a value in there and what is it? Do you have corresponding data on the database? Is table2 Nothing or does it contain data
Member 13755790 21-May-21 0:05am
   
table2 has data on it. it should be populated(combobox3) based on the text provided by the combobox2, where combox2.text is the name of the table from sqlconnection.
Wendelius 15-May-21 13:12pm
   
Are you sure this is the complete compiling code? You have an end if without corresponding if...
Member 13755790 15-May-21 20:28pm
   
thanks, please disregard the end if, i already deleted that line.thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900