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
Solved

Query results to data table

Posted on 2009-06-28
3
313 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
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where did System.Data.Objects go? 2 40
VB.Net WebRequest Code from JSON curl 7 48
How to seperate number and letters from a string 3 22
jquery tab header text 1 22
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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…

808 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