• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5913
  • Last Modified:

select statement against datatable (distinct, certian columns, etc)

Hey,

I have a question regarding doing a select statement against a datatable.  I'm familiar with datatable.select(...), but what I need/want is more doing a full select statement instead of just customizing the expression section of the select statement.  For example:

Datatable:
id     name     value
1      temp      1
2      temp      1
3      xxx         1
4      xxx         1
5      yy          1
6      yy          0
7      yy          0
8      yy          1

What sql I want against the datatable:
select distinct name, value from DATATABLE where value = 1

result:
name     value
temp      1
xxx         1
yy          1


I know I can do the where clause in the datatable.select(), but how would you do the distinct and then select certian columns?

Thanks in advance,
Kris
0
kdunnett
Asked:
kdunnett
  • 3
1 Solution
 
athapaCEO / CTOCommented:
You can filter using the RowFilter property of the dataview.
DataView has .ToTable method which lets you to only select distinct rows within the selected columns.

AT
0
 
kdunnettAuthor Commented:
Can you give an example?
0
 
kdunnettAuthor Commented:
is there something similiar to the .ToTable method in .net 1.1?
0
 
kdunnettAuthor Commented:
I found a ToTable method that someone created that mimic's the ToTable method in the 2.0 framework.

Thanks for pointing me in the right direction.

Kris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now