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
2 Replies - 579 Views - Last Post: 08 November 2012 - 11:47 AM
#1
i dont want to get duplicate values from datagridview in my combobox
Posted 08 November 2012 - 11:40 AM
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:
Replies To: i dont want to get duplicate values from datagridview in my combobox
#2
Re: i dont want to get duplicate values from datagridview in my combobox
Posted 08 November 2012 - 11:46 AM
Why not just go straight from the database to the combobox using a SELECT DISTINCT Query?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|