0

Hello Experts,

I have a dropdown list which is taking information from a database
in which i used as per below

SELECT DISTINCT * FROM [Devices]

but still it shows multiple same values.I want that the values are unique.How should I fix it ?
I already clicked -return only unique raws- under the sql databaseconnection settings still have multiple same values :(

3
Contributors
5
Replies
13
Views
3 Years
Discussion Span
Last Post by alpdoruk
1

You are performing a select on all fields in the table. A distinct in this case will return rows that are unique, not a particular field.

your drop down control is only using one field from the table so while your SQL distinct is working you still see duplicates in that one field.

So instead, your query should be something like this...

 SELECT DISTINCT field1 FROM [Devices]
0

wow thanks for the tip,this is the solution :) is there any other easy way for this ?in case that I don't want to create too much accessdatasources for this bindings.

0

is there any other easy way for this ?in case that I don't want to create too much accessdatasources for this bindings.

I'm not sure what you mean. I assume that what you are working with is a dropdownlist control and you want to populate it dynamically? If that is correct, yes you have to connect this control to a data source just like you did.

If not, you can add the items manually...

<asp:dropdownlist runat="server">
    <asp:ListItem>One</asp:ListItem>
    <asp:ListItem>Two</asp:ListItem>
    <asp:ListItem>Three</asp:ListItem>
</asp:dropdownlist>

if this did not solve your issue, please feel free to post more information.

Edited by JorgeM

0

Your first response solved my problem :) but i created 10 new database connection for each dropdownlist :)

This question has already been answered. 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.