Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can i check the dataset data is duplicate
Message
From
09/06/2011 16:06:39
 
 
To
09/06/2011 00:54:07
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01513740
Message ID:
01513903
Views:
37
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform