finding distinct column values in datatable 
Author Message
 finding distinct column values in datatable

I have created datatable name as Employees and columns as
EmpId,EmpName,Salary.

Datatable Employees contains the following data.

EmpId  EmpName                    Salary

1          Jone                 10000

2          Alex                 15000

3          George             12000

4          Smith                10000

5          Anna                15000

6          Steve                12000

7          Mark                14000

In above data salary is redundant. I want to select only unique salaries
(not duplicate).

How to find distinct salaries in datatable.

Thanks

Devesh



Fri, 08 Apr 2005 20:12:43 GMT  
 finding distinct column values in datatable
If your data is coming from a database then use the DISTINCT keyword to get
the salary data.  Otherwise some code like

        Dim iSalary As Integer
        Dim aSalary As New ArrayList()

        For Each objRow In objDT.Rows
            iSalary = Convert.ToInt32(objRow("Salary"))
            If Not aSalary.Contains(iSalary) Then
                aSalary.Add(iSalary)
            End If
        Next

        For Each iSalary In aSalary
            Debug.WriteLine(iSalary)
        Next


Quote:
> I have created datatable name as Employees and columns as
> EmpId,EmpName,Salary.

> Datatable Employees contains the following data.

> EmpId  EmpName                    Salary

> 1          Jone                 10000

> 2          Alex                 15000

> 3          George             12000

> 4          Smith                10000

> 5          Anna                15000

> 6          Steve                12000

> 7          Mark                14000

> In above data salary is redundant. I want to select only unique salaries
> (not duplicate).

> How to find distinct salaries in datatable.

> Thanks

> Devesh



Fri, 08 Apr 2005 21:01:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. finding distinct column values in datatable

2. Update column value for multiple rows in a datatable

3. Trouble adding rows to DataTable : Error = System.IndexOutOfRangeException: Cannot find column 2

4. Select Distinct on 1 column but return multiple columns

5. Find out the highest value of a column!

6. Datatable and column data types

7. datatable and column problemo (Again)

8. Problem using datatable.select using multiple columns

9. Inserting a new column in a DataTable

10. parameter source is DISTINCT (column) plus ALL

11. reducing DataTable.AutoIncrementSeed value...

12. DataTable Values

 

 
Powered by phpBB® Forum Software