Как получить 1 значение для каждой провинции в combobox
когда я выбираю регион, он показывает следующий регион, а когда я иду в провинцию, он показывает много провинций повторно, как, например, Себу, он показывает все Себу в combobox
все, что я хочу, это только 1 Себу будет видеть в combobox вместо многих Себу. то же самое с городом
Что я уже пробовал:
Private Sub cboRegion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboRegion.SelectedIndexChanged Dim oledr As OleDb.OleDbDataReader Connection = "select * from Address where Region = '" & cboRegion.Text & "'" cboProvince.Items.Clear() Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = Connection acscmd.Connection = OleCn oledr = acscmd.ExecuteReader() While (oledr.Read()) cboProvince.Items.Add(oledr("Province")) End While cboProvince.SelectedIndex = -1 acscmd.Dispose() oledr.Close() End Sub
Private Sub cboProvince_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboProvince.SelectedIndexChanged Dim oledr As OleDb.OleDbDataReader Connection = "select * from Address where Province = '" & cboProvince.Text & "'" cboCity.Items.Clear() Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = Connection acscmd.Connection = OleCn oledr = acscmd.ExecuteReader() While (oledr.Read()) cboCity.Items.Add(oledr("City")) End While cboCity.SelectedIndex = -1 acscmd.Dispose() oledr.Close() End Sub
Private Sub cboCity_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCity.SelectedIndexChanged Dim oledr As OleDb.OleDbDataReader Connection = "select * from Address where City = '" & cboCity.Text & "'" cboBrgy.Items.Clear() Dim acscmd As New OleDb.OleDbCommand acscmd.CommandText = Connection acscmd.Connection = OleCn oledr = acscmd.ExecuteReader() While (oledr.Read()) cboBrgy.Items.Add(oledr("Barangay")) End While cboBrgy.SelectedIndex = -1 acscmd.Dispose() oledr.Close() End Sub