0

i have a database table and it has some column with duplicate values , and i want to get that column value of the table in a combobox, but i want every value single time not repeatedly ... i tried but it is still giving me all values in the combobox:

i have a database table and it has some column with duplicate values  , and i want to get that column value of the table in a combobox, but  i want every value single time not repeatedly ... i tried but it is still giving me all values in the combobox:
<pre lang="vb">
        Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=grade;Integrated Security=True;Pooling=False")
        Dim cmd As SqlCommand
        Dim Classes As New List(Of String)
        Try
            conn.Open()
            Dim query As String = "SELECT Class FROM Class"
            cmd = New SqlCommand(query, conn)
            Dim rd As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
            While rd.Read()
                Classes.Add(rd("Class").ToString)
            End While
            rd.Close()
            conn.Close()

            Me.ComboClass.Items.Clear()
            Me.ComboClass.Items.AddRange(Classes.ToArray)

        Catch ex As Exception
            MessageBox.Show(ex.ToString())


        End Try
</pre>
2
Contributors
1
Reply
4
Views
4 Years
Discussion Span
Last Post by Reverend Jim
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.