Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Merge Duplicate Rows In DataSet
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01472170
Message ID:
01472206
Views:
41
>I have a dataset with 2 columns, Item and Quantity. The user can enter any value in Item, and any number in quantity. I would like to combine duplictes.
>
>Kevin, DataTable.DefaultView has a method called ToTable, and one of the overloads allows you to do the equivalent of a DISTINCT. Take a look at one of the overloads for ToTable
>
>So it could be as simple as...
>
>
>DataTable dtNewTable = dtOldTable.DefaultView.ToTable(true, "Column1", "Column2", etc.)

I have this:
DataTable dtNewTable = csCOSApp.ActiveProject.dsQuery.Tables[0].DefaultView.ToTable(true, new string[] { "Item", "Quantity" });
dtNewTable is the same as the source table. This doesn't work either:
DataTable dtNewTable = csCOSApp.ActiveProject.dsQuery.Tables[0].DefaultView.ToTable(true, "Item", "Quantity");
See this: www.marois-consulting.com/files/duplictes.jpg. You can see that the first 3 rows are duplicated. The result should be 1 row with a quantity of 15.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform