首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

数据提取有关问题

2012-03-21 
数据提取问题例:数据表AA,如下idcustomerqtyyearmonth1mac400201112mac4800201123mac10201134mac85201141o

数据提取问题
例:数据表AA,如下
id customer qty year month
1 mac 400 2011 1
2 mac 4800 2011 2
3 mac 10 2011 3
4 mac 85 2011 4
1 oll 400 2011 1
2 oll 4800 2011 2
3 oll 10 2011 3
4 oll 85 2011 4

现在我想要做的是把customer相同的提取出来,我怎么对比customer是否相同


[解决办法]
DataSet set1 = WebData1.dataSet(sql1);
Hashtable ht=new Hashtable();
for (int ii = 0; ii < set1.Tables[0].Rows.Count; ii++)
{

if(ht.ContainKey(et1.Tables[0].Rows[ii]["customer"].ToString()))
{
((ArrayList)ht.Get(et1.Tables[0].Rows[ii]["customer"].ToString())).Add(et1.Tables[0].Rows[ii]);
}
else
{
ArrayList al=new ArrayList();
al.Add(et1.Tables[0].Rows[ii]);
ht.Put(et1.Tables[0].Rows[ii]["customer"].ToString()),al);
}
}
用哈希表实现就行了

热点排行