[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5900
  • 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
 
athapaCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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