Avatar of PeterBaileyUk
PeterBaileyUk

asked on 

combo not populating in vb.net

I have a small sub that gets the data, everything is fine up until I get to the add items to the combo, the string variables are populated correctly, I appear to have mishandled the actual .add but cannot see why

I did look at the microsoft website I havnt posted the link
but it says: ' Visual Basic
ComboBox1.Items.Add("Tokyo")



    Private Sub GetCBChords()
        Dim StrProcName As String
        Dim StrWord As String
        Dim dtChord As DataTable
        Dim Stri As String
        Dim Strii As String
        Dim Striii As String
        Dim Striv As String
        Dim Strv As String
        Dim Strvi As String
        Dim Strvii As String
        Dim Strdim7 As String


        Dim connectionString As String = "Data Source=MAIN-PC\SQLEXPRESS;Initial Catalog=PushCircle;Integrated Security=True;MultipleActiveResultSets=True"
        dtChord = New DataTable



        StrProcName = "usp_GetChords"
        Using connChord As New SqlConnection(connectionString)
            Using cmdChord As New SqlCommand(StrProcName, connChord)
                cmdChord.CommandType = CommandType.StoredProcedure
                connChord.Open()
                cmdChord.Parameters.AddWithValue("@Tonic", CBNote.SelectedItem.ToString())
                cmdChord.Parameters.AddWithValue("@ScaleType", CBScaleType.SelectedItem.ToString())
                Dim reader As SqlDataReader = cmdChord.ExecuteReader()

                dtChord.Load(reader)


                For Each drRecord As DataRow In dtChord.Rows
                    Stri = drRecord("i")
                    Strii = drRecord("ii")
                    Striii = drRecord("iii")
                    Striv = drRecord("iv")
                    Strv = drRecord("v")
                    Strvi = drRecord("vi")
                    Strvii = drRecord("vii")
                    Strdim7 = drRecord("dim7")

                Next
                CBScaleType.Items.Add(Stri)
                CBScaleType.Items.Add(Strii)
                CBScaleType.Items.Add(Striii)
                CBScaleType.Items.Add(Striv)
                CBScaleType.Items.Add(Strv)
                CBScaleType.Items.Add(Strvi)
                CBScaleType.Items.Add(Strvii)
                CBScaleType.Items.Add(Strdim7)



            End Using
        End Using


    End Sub

Open in new window

Visual Basic.NET

Avatar of undefined
Last Comment
PeterBaileyUk

8/22/2022 - Mon