This is a discussion on Removing duplicate rows in a DataSet within the ASP and ASP.NET Programming forums, part of the Web Development category; How to remove the duplicate rows in a dataset...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| This method will remove the duplicate rows from a datatable, based on a column. Pass to the method the datatable and the column to be checked for duplicate values. Call the method like this : RemoveDuplicateRows(dT,"ID"); This is the implementation. public void RemoveDuplicateRows(DataTable dTable,string colName) { Hashtable hTable = new Hashtable(); ArrayList duplicateList = new ArrayList(); foreach(DataRow drow in dTable.Rows) { try { hTable.Add(drow[colName],string.Empty); } catch { duplicateList.Add(drow); } } foreach(DataRow dRow in duplicateList) dTable.Rows.Remove(dRow); } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing multiple spaces from string | bluesky | C# Programming | 3 | 03-19-2008 06:17 AM |
| Duplicate Content | vadivelanvaidyanathan | Search Engine Optimization | 11 | 02-27-2008 11:10 AM |
| Info on removing pages history | Jeyaseelansarc | PHP Programming | 2 | 09-25-2007 09:04 AM |
| Duplicate elements from an array | vigneshgets | C and C++ Programming | 1 | 09-06-2007 08:04 AM |
| Can anybody explain about the differences between dataset.clone and dataset.copy? | kingmaker | C# Programming | 2 | 08-28-2007 12:22 AM |