Hi all!
I am writting beacause I desperately want your help..
I want to connect 3 comboboxes. I have a table which contains Streetnames, Post Codes and Municipalities. I want to choose the Streetname from the first combobox something that I have done. The second Combobox I want to display the possible Post Codes. The problem is that the same streetname may belongs to more than one municipality which means that one streetname should display more than one post code at combobox 2 and more than one municiality in combobox 3. I attach my code till now..I achieved to fill the first combo box and i need your help for the second one.. What I do wrong??
Dim StreetNameDA As New SqlDataAdapter()
Dim DSstreetName1 As New AMRtoSQLDataSet
'DSstreetName1.Clear()
'Select Street Names
StreetNameDA.SelectCommand = New SqlCommand()
StreetNameDA.SelectCommand.Connection = conn
StreetNameDA.SelectCommand.CommandText = "SELECT StreetName_LCL FROM T_MUNICIPALITY_STREETS order by StreetName_LCL"
StreetNameDA.Fill(DSstreetName1, "StreetNameTable")
'-------------Fill combo box StreeName1
'Dim PC As String
cboStreetName1.DataSource = DSstreetName1.Tables("StreetNameTable")
cboStreetName1.DisplayMember = "StreetName_LCL"
' PC = cboStreetName1.ValueMember
cboStreetName1.ValueMember = "StreetName_LCL"
Me.cboStreetName1.SelectedValue = 0
'-------------fill post code combobox
Dim PostcodeDA As New SqlDataAdapter()
Dim DSpostcode As New AMRtoSQLDataSet
' DSpostcode.Clear()
' Dim SN As String
PostcodeDA.SelectCommand = New SqlCommand()
PostcodeDA.SelectCommand.Connection = conn
PostcodeDA.SelectCommand.CommandText = "SELECT Postcode,StreetName_LCL FROM T_MUNICIPALITY_STREETS WHERE StreetName_LCL= '" & cboStreetName1.SelectedIndex.ToString & "'"
PostcodeDA.Fill(DSpostcode, "PostcodeTable")
cboPostcode.DataSource = DSpostcode.Tables("PostcodeTable")
cboPostcode.DisplayMember = "Postcode"
cboPostcode.ValueMember = "Postcode"
cboPostcode.SelectedValue = 0