IEnumerable<DataRow> uniqueRows = table.AsEnumerable().Distinct(DataRowComparer.Default); foreach (DataRow uniqueRow in uniqueRows) { arrayList.Add(uniqueRow.Column); }
Life is a Race Thanks & Regards By Sabari Mahesh P M
Thanks & Regards By Jeniffer Shamin .S.P
public DataTable DuplicateRowRemove(DataTable dt, string Col) { Hashtable hTable = new Hashtable(); ArrayList ArrDupli = new ArrayList(); foreach (DataRow r in dt.Rows) { if (HeshTbl.Contains(r[Col])) ArrDupli.Add(r); else HeshTbl.Add(r[Col], string.Empty); } foreach (DataRow R in ArrDupli) dt.Rows.Remove(R); return dt; }
using System.Data; using System.Linq; ... //assuming 'ds' is your DataSet //and that ds has only one DataTable, therefore that table's index is '0' DataTable dt = ds.Tables[0]; DataView dv = new DataView(dt); string cols = string.Empty; foreach (DataColumn col in dt.Columns) { if (!string.IsNullOrEmpty(cols)) cols += ","; cols += col.ColumnName; } dt = dv.ToTable(true, cols.Split(',')); ds.Tables.RemoveAt(0); ds.Tables.Add(dt);
Login to post response