i have a combobox that binding to table , what i need is wneh i retured the data i dont want to duplicate entries
for example i have combobox with item BOQ Section and the item as the following "concrete , concrete, concrete , Utilities , utilities, concrete, AirCondiotioning ,utilities, concrete, AirCondiotioning"

i just need to retrun :"concrete , Utilities, AirConditoning"

how i can do this ????
thanx

i am trying to do but it gives me the same result: 


 Public Function Find() As DataTable
           Getconnection()  
        Dim sql As String = "SELECT DISTINCT BOQDetailEntry.BOQDetailEntryID, BOQDetailEntry.ProjectTenderingNO,  BOQDetailEntry.BOQSection, BOQDetailEntry.Part, BOQDetailEntry.BOQITEM, BOQDetailEntry.Description, BOQDetailEntry.Unit, BOQDetailEntry.BOQTY, BOQDetailEntry.ReferenceDrawing, BOQDetailEntry.ReferenceSpecifications FROM BOQDetailEntry WHERE 1=1 "
           Dim dt As New DataTable
           Dim da As New SqlDataAdapter(sql, Me.conn)
           If _BOQDetailEntryID<> 0 Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.BOQDetailEntryID = @BOQDetailEntryID"
               da.SelectCommand.Parameters.Add("@BOQDetailEntryID", SqlDbType.Int).Value = _BOQDetailEntryID
           End If
           If _ProjectTenderingNO <> "" Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.ProjectTenderingNO Like @ProjectTenderingNO"
               da.SelectCommand.Parameters.Add("@ProjectTenderingNO", SqlDbType.varchar).Value = _ProjectTenderingNO & "%"
           End If
           If _BOQSection <> "" Then
            da.SelectCommand.CommandText &= "  AND BOQDetailEntry.BOQSection Like @BOQSection"
               da.SelectCommand.Parameters.Add("@BOQSection", SqlDbType.varchar).Value = _BOQSection & "%"
           End If
           If _Part <> "" Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.Part Like @Part"
               da.SelectCommand.Parameters.Add("@Part", SqlDbType.varchar).Value = _Part & "%"
           End If
           If _BOQITEM <> "" Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.BOQITEM Like @BOQITEM"
               da.SelectCommand.Parameters.Add("@BOQITEM", SqlDbType.varchar).Value = _BOQITEM & "%"
           End If
           If _Description <> "" Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.Description Like @Description"
               da.SelectCommand.Parameters.Add("@Description", SqlDbType.varchar).Value = _Description & "%"
           End If
           If _BOQTY <> 0 Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.BOQTY = @BOQTY"
               da.SelectCommand.Parameters.Add("@BOQTY", SqlDbType.money).Value = _BOQTY
           End If
           If _ReferenceDrawing <> "" Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.ReferenceDrawing Like @ReferenceDrawing"
               da.SelectCommand.Parameters.Add("@ReferenceDrawing", SqlDbType.varchar).Value = _ReferenceDrawing & "%"
           End If
           If _ReferenceSpecifications <> "" Then
               da.SelectCommand.CommandText &= " AND BOQDetailEntry.ReferenceSpecifications Like @ReferenceSpecifications"
               da.SelectCommand.Parameters.Add("@ReferenceSpecifications", SqlDbType.varchar).Value = _ReferenceSpecifications & "%"
           End If
       Try
   Getconnection()
           da.Fill(dt)
       Catch ex As SqlException
           Me._Msg="Error Message"
       Finally
           Try
               Me.conn.Close()
           Catch
           End Try
       End Try
       Return dt
   End Function

You use SELECT DISTINCT when retrieving one field only and the syntax is

SELECT DISTINCT(fieldname) FROM tablename
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.