string result = ""; Hashtable ht = new Hashtable(); foreach(DataRow dr in ds.Tables[0]) { string name = getDataValue(dr["Name"]); if(!ht.ContainKey(name)) { ht.add(name,""); } }
foreach(string key in ht.keys) { result += key + ","; } return result.substring(0,result.length-1);//support function private string getDataValue(object dataValue) { if(dataValue == null) return "" ; return dataValue.ToString(); }
private string str = ""; for (int i = 0;i<DataSet.Tables["表名"].Rows.Count;i++) { str += DataSet.Tables["表名"].Rows[i]["列名"].ToString(); }
循环遍历一遍你的表,然后从每行里拿出name来,插入一个string
循环遍历一遍你的表,然后从每行里拿出name来,插入一个string一盘不的行吗,你真么找到哪些name相同的,不同的呢?
Hashtable ht = new Hashtable();
foreach(DataRow dr in ds.Tables[0])
{
string name = getDataValue(dr["Name"]);
if(!ht.ContainKey(name))
{
ht.add(name,"");
}
}
foreach(string key in ht.keys)
{
result += key + ",";
}
return result.substring(0,result.length-1);//support function
private string getDataValue(object dataValue)
{
if(dataValue == null)
return "" ;
return dataValue.ToString();
}
for (int i = 0;i<DataSet.Tables["表名"].Rows.Count;i++)
{
str += DataSet.Tables["表名"].Rows[i]["列名"].ToString();
}