Data Table

prav_roy

Well-known member
Joined
Sep 10, 2005
Messages
70
Location
Mumbai
Programming Experience
1-3
hi,
i have a datagrid and im using a datatable as a datasource for datagrid..
since there are some repeated values in the data source(SQL).. when i bind the datagrid i get repeated rows..
my question.. is there any way out to filter only those rows from datatable which are not repeated..
thank u
 
I think you want to look into adding the keyword "Distinct" to your SQL select statement. That way you start out with the data you want rather than trying to exclude the duplicates.
 
thank you for your reply, but do you think it is possible to get distinct employeenames from a table where i am not only retrieving employeenames but also three more fields...
ie SELECT field1,field2,field3 from TABLE
where my employeename repeats..
Thank you
 
Curious...
In order for 'DISTINCT' to work the way you want, all three fields must be identical. If one field is different that record fails the distinct check.

Tell me more about what you are dealing with.
When you say there are 'repeated rows', is the entire row the same? If this is true, Distinct should work.
Is this a new database or one you inherited? (can we change it's structure?)
What fields are you dealing with? Names, type, and possible values.
What is the purpose for 'duplicate values in the datasource', are we talking about 3 women with the last name 'Smith'?
What is the "KEY' for that table, or is there one?

Repeated values in the data source(SQL) will often fail the good structure model for a datatable. It implies poor key value structure, or trying to capture a one to many relationship in a single table. Let's see what you have and see what we can do.
 
To make you very clear, i am not taking the values from single table.. im using some sql join queries..
its just like employee-project relation wherein a employee can work in more than one project right..
after executing tht query im filling the data in datatable.. from datatable i only want to fill combobox with employees names.. and problem lies here as im retrieving multiple names my combobox shows multiple names..
 
Ok, I give up. Sorry, I have no idea how to do want you want.

Possible suggestions, strategies:
Bind the combobox to a seperate dataset that uses 'distinct' to fill the table with just the names. Filter or sort the joined datatable based on the selected index of the combobox.
 
DavidT_macktool said:
Ok, I give up. Sorry, I have no idea how to do want you want.

Possible suggestions, strategies:
Bind the combobox to a seperate dataset that uses 'distinct' to fill the table with just the names. Filter or sort the joined datatable based on the selected index of the combobox.
That's the way I'd do it.....

-tg
 
Back
Top