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

Posted on 2006-04-24
Last Modified: 2008-01-09

I have a question regarding doing a select statement against a datatable.  I'm familiar with, 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:

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

name     value
temp      1
xxx         1
yy          1

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

Thanks in advance,
Question by:kdunnett
    LVL 10

    Accepted Solution

    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.


    Author Comment

    Can you give an example?

    Author Comment

    is there something similiar to the .ToTable method in .net 1.1?

    Author Comment

    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.


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now