Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can i check the dataset data is duplicate
Message
De
09/06/2011 16:06:39
 
 
À
09/06/2011 00:54:07
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01513740
Message ID:
01513903
Vues:
38
>Hi all,
> I use vb.net and dataset ... i write a function add the row in dataset. But if the key is duplicate,then not add it .
>So I want to check the dataset data . How can i do, thank you ..... May you give me idea , can use sql to check it in dataset data?.....


If all you need to check is the data in the existing DataSet/DataTable, there are a number of methodologies you could use. LINQ would work, but I don't have the LINQ syntax memorized. However, I *do* know the DataTable.Select() method off the top of my head, so I'll show you the .Select():
DataRow[] rows = MyDataSet.Tables["MyTable"].Select("MyKey = " + NewKey)
if (rows.Length > 0)   ' NewKey already exists, so you've got a duplicate
The above isn't actually VB, so I probably have the syntax wrong in that first line, but you get the idea ...

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform