i have two combobox and i have two database table in sql server 1st table name is Province and 2nd table name is City if i select province in my 1st combobox then show all cities against selected province show in the 2nd combobox when we click on combobox dropdown list so plz help me how i can do this in vb.net 2010

Recommended Answers

All 2 Replies

Please post your codes , how far you write and describe your probs and exceptions what are you facing. Everyone in this forum always you to help, don't hesitate to post your Qse.

bro this is my code but this code can not be use to relationship for province and city so plz help me.
plz give me code if any body can do this relation
i have two combobox and i have two database table in sql server 1st table name is Province and 2nd table name is City if i select province in my 1st combobox then show all cities against selected province show in the 2nd combobox when we click on combobox dropdown list so plz help me how i can do this in vb.net 2010

If Province2.DataSource = "Punjab" Then

       Dim cmd As New SqlCommand("Select City from Table_9", nn)
        Dim da As New SqlDataAdapter(cmd)

       Dim dt As New DataTable()
        da.Fill(dt)

       If dt.Rows.Count > 0 Then
            ComboBox1.DataSource = dt
           ComboBox1.DisplayMember = "City"
        End If

    End If
    If Province2.DataSource = "Sindh" Then


    Dim cmd As New SqlCommand("Select City from Table_10", nn)
       Dim da As New SqlDataAdapter(cmd)

       Dim dt As New DataTable()
        da.Fill(dt)
        If dt.Rows.Count > 0 Then
            ComboBox1.DataSource = dt
            ComboBox1.DisplayMember = "City"
        End If
    End If  
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.