|
-
February 4th, 2010, 04:31 PM
#1
[RESOLVED] LINQ Grouping
I'm having a heck of a time with this. I'm trying to get some distinct values from an XML table.
I've looked at using distinct but that wasn't working at all so thought I'd just group by the element I want distinct and only return that field. LINQ is busting my chops man, it just doesn't make any sense to me.
It seems like it is returning all records. As I debug and go through the loop, the branch.value isn't changing. There are 17000 "row"s in the xml but only 3 distinct "USRDEFND5".
Here's the code I'm currently using:
Code:
branch_ids = From b In xmlFile.Descendants.Elements("row") Group By bid = b.Element("USRDEFND5") Into Group Select bid
For Each branch As XElement In branch_ids
myConnection.Open()
myCommand = New SqlCommand("DELETE FROM " & files(i) & " WHERE USRDEFND5 = '" & branch.Value & "'", myConnection)
dr = myCommand.ExecuteReader()
dr.Close()
myConnection.Close()
Next
Thanks for any help.
Last edited by stin; February 4th, 2010 at 04:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|