Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Merge Duplicate Rows In DataSet
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01472170
Message ID:
01472206
Vues:
42
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform