IT Community - Software Programming, Web Development and Technical Support

Removing duplicate rows in a DataSet

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...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-13-2008, 09:29 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Removing duplicate rows in a DataSet

How to remove the duplicate rows in a dataset
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-13-2008, 09:30 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: Removing duplicate rows in a DataSet

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);
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-13-2008, 09:33 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Removing duplicate rows in a DataSet

I m getting the situation to pass multiple columns
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 06:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0