Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vb.net 2008 .AsEnumerable output struggles

Status
Not open for further replies.

rw409168

Programmer
Jul 16, 2009
95
GB
Greetings,

I have a datatable which contains xml data.

The LINQ code within the thread selects the datarow based on a criteria.

The problem lies no matter what I try I can never get the values as xml/string data, I often see the literal words "System.data.datarow" or simalar rather than the data.

The datatable has rows and I can print the values using a for each loop, however as using LINQ require .AsEnumberable to query the datatable.

The plan was once retrieving the XML then add it to a NEW xmldocument as an xmlElement
Code:
 Dim outQuoteDoc As New XDocument(New XElement("quotefile", quotes)

Code:
Dim quotes = From quote In frmMainQuote.quoteData.Tables("quote").AsEnumerable _
                        Where quote.Item("category").ToString = cboCategory.SelectedItem.ToString _
                        And quote.Item("author").ToString = txtAuthor.Text _
                        And quote.Item("text").ToString Like "*" & txtKeyword.Text & "*" _
                        And quote.Item("date").ToString = dtpQuoteDate.Value.ToString("dd MMMM yyyy") _
                        Select quote.Tostring()

I've messed around between formats and even tried anonymous types but can never get the datarow values out as xml/string.

This is causing me a migraine!!

Could really do with a helping hand to query the datatable and retrieve xml output, any tips or advice?


Thanks
Rob
 
Issue resolved via created a new datatable and using the dataset writexml method to have a valid xml file :)

Code:
Dim dd As New DataSet

dd.Tables.Add(frmMainQuote.quoteData.Tables("quote").Clone)

For Each ee In quotes
dd.Tables("quote").ImportRow(ee)
Next

dd.WriteXml("name.xml")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top