如何在数据表中选择不同的行并存储到数组中 [英] How to select distinct rows in a datatable and store into an array

查看:126
本文介绍了如何在数据表中选择不同的行并存储到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集objds。 objds包含一个名为Table1的表。 Table1包含名为ProcessName的列。这个ProcessName包含重复的名称,所以我只想选择不同的名字。这是可能的。

  intUniqId [i] =(objds .Tables [0] .Rows [i] [ProcessName]。ToString()); 


解决方案

  DataView视图=新的DataView(表); 
DataTable distinctValues = view.ToTable(true,Column1,Column2...);


I have a dataset objds. objds contains a table named Table1. Table1 contains column named ProcessName. This ProcessName contains repeated names.So i want to select only distinct names.Is this possible.

  intUniqId[i] = (objds.Tables[0].Rows[i]["ProcessName"].ToString());

解决方案

DataView view = new DataView(table);
DataTable distinctValues = view.ToTable(true, "Column1", "Column2" ...);

这篇关于如何在数据表中选择不同的行并存储到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆