Solved

Query results to data table

Posted on 2009-06-28
3
314 Views
Last Modified: 2013-11-11
I need to build a table with the results of different LINQ queries.  I was trying to do this with a data table but now sure of the syntax.  An example of what I'm trying to do is below.
After I add all the columns and create all the other LINQ queries, How do I add/update the data table with the results? Or is there a better way then using a data table? Was I build the table and create calculate columns the end results will end up in an excel spreadsheet.
Using VB 2008  framework 3.5.
Thanks


Dim ResultsTable as DataTable
Dim dc As New dcDSSDataContext
 
Dim TMADODList = From TMA In dc.vwCurrentTMA _
     Select TMA.DOD
Dim InterChgDODList = From IC In dc.datInterchangeableDOD _
      Select IC.DOD
 
Dim DODList = TMADODList.Union(InterChgDODList )
DODList = DODList.Distinct
 
ResultsTable = New DataTable("Results")
 
ResultsTable.Columns.Add("DOD", GetType(String))
ResultsTable.Columns.Add("Location", GetType(String))
'Other columns added here

Open in new window

0
Comment
Question by:MadIce
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 500 total points
ID: 24732988
Think below will guide you in right way:

Creating a DataTable From a Query (LINQ to DataSet) ( http://msdn.microsoft.com/en-us/library/bb386921.aspx  )
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24733008
0
 

Author Comment

by:MadIce
ID: 24733343
I get CopyToDataTable() is not a member of System.Liq.IQueryable(Of String) error. Do I need to add a reference?
I got the datatable to add new rows with the following
For Each DOD in DODList
    ResultsTable.Rows.Add(New Object() {DOD})
Next

But how do I update Columns with the results of a different LINQ query?  I want to update the second Query?
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sort GridView by ID Descending 1 24
VB.NET 2008 Winforms Signing 13 42
MailAddress in vb 4 36
Change to file doesn't show up 16 77
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question